日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Swordsman

發布時間:2023/12/10 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Swordsman 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ps:比賽的時候想到了做法,k次排序,然后每次消去能消的。。。然而這種做法是錯誤的,神奇的是測試案例中排在奇數的案例會WA,排在偶數的案例都過了,被注釋的代碼會T.

#include<bits/stdc++.h> #define ULL unsigned long long #define LL long long #define P pair<int, int> #define pb push_back #define mp make_pair #define pp pop_back #define lson root << 1 #define INF32 (int)2e9 + 7 #define rson root << 1 | 1 #define INF64 (unsigned long long)1e18 #define sc(x) scanf("%d", &x) #define pr(x) printf("%d\n", x) #define mem(arry, in) memset(arry, in, sizeof(arry)) #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std;namespace fastIO {#define BUF_SIZE 100000bool IOerror = 0;inline char nc() {static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;if(p1 == pend) {p1 = buf;pend = buf + fread(buf, 1, BUF_SIZE, stdin);if(pend == p1) {IOerror = 1;return -1;}}return *p1++;}inline bool blank(char ch) {return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';}inline void read(int &x) {char ch;while(blank(ch = nc()));if(IOerror) return;for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');}#undef BUF_SIZE }; using namespace fastIO;inline void upd(int &x, int y) { x < y && (x = y); }const int N = 100005;P a[15][N]; int T, n, k, v[10], b[N][15], point[15], cnt[N], c[N][15]; bool use[N];int main() {//freopen("D:\\1.in", "r", stdin);//freopen("D:\\1.txt", "w", stdout); read(T);while(T--) {read(n), read(k);for (int i = 1; i <= k; ++i) read(v[i]);for (int i = 1; i <= n; ++i) {for (int j = 1; j <= k; ++j) {read(a[j][i].first);a[j][i].second = i;//c[i][j] = a[j][i].first; }for (int j = 1; j <= k; ++j) read(b[i][j]);}mem(cnt, 0);mem(point, 0);//mem(use, 0);int ans = 0;for (int i = 1; i <= k; ++i) sort(a[i] + 1, a[i] + 1 + n);/*
// 寫的代碼真的很搓,也許換種優秀的寫法就過了sort(a[1] + 1, a[1] + n + 1);while(1) {int oldans = ans;for (int j = 1; j <= n; ++j) if (!use[a[1][j].second]) {int id = a[1][j].second;if (c[id][1] > v[1]) break;int tot = 0;for (int q = 1; q <= k; ++q) if (c[id][q] <= v[q]) {tot++;}if (tot == k) {for (int q = 1; q <= k; ++q) v[q] += b[id][q];use[id] = 1;ans++;}}if (oldans == ans) break;}
*/while(1) {int oldans = ans;for (int i = 1; i <= k; ++i) {while(point[i] < n && a[i][point[i] + 1].first <= v[i]) {int x = a[i][++point[i]].second;cnt[x]++;if (cnt[x] == k) {++ans;for (int j = 1; j <= k; ++j) v[j] += b[x][j];}}}if (oldans == ans) break;}pr(ans);for (int i = 1; i < k; ++i) printf("%d ", v[i]);pr(v[k]);}return 0; }

?

轉載于:https://www.cnblogs.com/zgglj-com/p/9474734.html

總結

以上是生活随笔為你收集整理的Swordsman的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。