結果
問題 | No.918 LISGRID |
ユーザー | tko919 |
提出日時 | 2019-10-26 19:20:55 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 1,647 bytes |
コンパイル時間 | 1,826 ms |
コンパイル使用メモリ | 176,836 KB |
実行使用メモリ | 16,616 KB |
最終ジャッジ日時 | 2023-10-12 17:41:11 |
合計ジャッジ時間 | 8,062 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,600 KB |
testcase_01 | AC | 36 ms
13,316 KB |
testcase_02 | AC | 13 ms
9,648 KB |
testcase_03 | AC | 17 ms
10,136 KB |
testcase_04 | AC | 14 ms
9,668 KB |
testcase_05 | AC | 45 ms
14,084 KB |
testcase_06 | AC | 41 ms
13,792 KB |
testcase_07 | AC | 61 ms
16,184 KB |
testcase_08 | AC | 33 ms
12,768 KB |
testcase_09 | AC | 44 ms
14,268 KB |
testcase_10 | AC | 44 ms
14,344 KB |
testcase_11 | AC | 45 ms
14,472 KB |
testcase_12 | AC | 48 ms
15,056 KB |
testcase_13 | AC | 40 ms
13,696 KB |
testcase_14 | AC | 59 ms
15,820 KB |
testcase_15 | AC | 68 ms
16,616 KB |
testcase_16 | AC | 22 ms
11,264 KB |
testcase_17 | AC | 26 ms
11,440 KB |
testcase_18 | AC | 23 ms
11,404 KB |
testcase_19 | AC | 9 ms
8,960 KB |
testcase_20 | AC | 30 ms
12,408 KB |
testcase_21 | AC | 11 ms
9,020 KB |
testcase_22 | AC | 8 ms
8,608 KB |
testcase_23 | AC | 19 ms
10,912 KB |
testcase_24 | AC | 5 ms
7,872 KB |
testcase_25 | AC | 4 ms
7,556 KB |
testcase_26 | AC | 4 ms
7,484 KB |
testcase_27 | AC | 4 ms
7,540 KB |
testcase_28 | AC | 3 ms
7,412 KB |
testcase_29 | AC | 4 ms
7,556 KB |
testcase_30 | AC | 4 ms
7,488 KB |
testcase_31 | AC | 4 ms
7,532 KB |
testcase_32 | AC | 4 ms
7,564 KB |
testcase_33 | AC | 3 ms
7,512 KB |
testcase_34 | AC | 5 ms
7,904 KB |
testcase_35 | AC | 6 ms
8,260 KB |
testcase_36 | AC | 4 ms
7,756 KB |
testcase_37 | AC | 29 ms
12,380 KB |
testcase_38 | AC | 21 ms
10,932 KB |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; typedef pair<ll, ll> P; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);} const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff; //template end vector<P> edge[410][410]; int cnt[410][410]={}; int ans[410][410]; int main(){ int h,w; scanf("%d%d",&h,&w); vector<int> a(h),b(w); rep(i,0,h)scanf("%d",&a[i]); rep(i,0,w)scanf("%d",&b[i]); sort(ALL(a)); sort(ALL(b)); rep(i,0,h){ rep(j,0,w-a[i])edge[i][j].push_back({i,j+1}),cnt[i][j+1]++; rep(j,w-a[i],w-1)edge[i][j+1].push_back({i,j}),cnt[i][j]++; } rep(j,0,w){ rep(i,0,h-b[j])edge[i][j].push_back({i+1,j}),cnt[i+1][j]++; rep(i,h-b[j],h-1)edge[i+1][j].push_back({i,j}),cnt[i][j]++; } queue<P> q; int d=h*w; rep(i,0,h)rep(j,0,w)if(!cnt[i][j])q.push({i,j}); while(!q.empty()){ auto now=q.front(); q.pop(); int x=now.first,y=now.second; ans[x][y]=d; d--; for(auto nxt:edge[x][y]){ cnt[nxt.first][nxt.second]--; if(!cnt[nxt.first][nxt.second])q.push({nxt}); } } rep(i,0,h){ rep(j,0,w)printf("%d ",ans[i][j]); puts(""); } return 0; }