結果
問題 | No.918 LISGRID |
ユーザー | leaf_1415 |
提出日時 | 2019-10-25 23:10:42 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 1,279 bytes |
コンパイル時間 | 2,591 ms |
コンパイル使用メモリ | 69,548 KB |
実行使用メモリ | 15,444 KB |
最終ジャッジ日時 | 2023-10-11 09:09:52 |
合計ジャッジ時間 | 5,217 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
9,384 KB |
testcase_01 | AC | 25 ms
12,676 KB |
testcase_02 | AC | 12 ms
10,484 KB |
testcase_03 | AC | 14 ms
10,908 KB |
testcase_04 | AC | 13 ms
10,664 KB |
testcase_05 | AC | 34 ms
13,280 KB |
testcase_06 | AC | 31 ms
13,084 KB |
testcase_07 | AC | 46 ms
15,292 KB |
testcase_08 | AC | 29 ms
12,500 KB |
testcase_09 | AC | 35 ms
13,524 KB |
testcase_10 | AC | 35 ms
13,340 KB |
testcase_11 | AC | 33 ms
13,584 KB |
testcase_12 | AC | 37 ms
13,868 KB |
testcase_13 | AC | 28 ms
13,020 KB |
testcase_14 | AC | 40 ms
14,716 KB |
testcase_15 | AC | 48 ms
15,444 KB |
testcase_16 | AC | 19 ms
11,404 KB |
testcase_17 | AC | 21 ms
11,688 KB |
testcase_18 | AC | 19 ms
11,536 KB |
testcase_19 | AC | 8 ms
10,048 KB |
testcase_20 | AC | 23 ms
12,268 KB |
testcase_21 | AC | 9 ms
10,260 KB |
testcase_22 | AC | 7 ms
10,152 KB |
testcase_23 | AC | 16 ms
11,204 KB |
testcase_24 | AC | 5 ms
9,464 KB |
testcase_25 | AC | 4 ms
9,444 KB |
testcase_26 | AC | 5 ms
9,524 KB |
testcase_27 | AC | 4 ms
9,380 KB |
testcase_28 | AC | 5 ms
9,564 KB |
testcase_29 | AC | 4 ms
9,320 KB |
testcase_30 | AC | 4 ms
9,320 KB |
testcase_31 | AC | 4 ms
9,604 KB |
testcase_32 | AC | 4 ms
9,384 KB |
testcase_33 | AC | 4 ms
9,376 KB |
testcase_34 | AC | 5 ms
9,472 KB |
testcase_35 | AC | 6 ms
9,840 KB |
testcase_36 | AC | 4 ms
9,464 KB |
testcase_37 | AC | 27 ms
12,312 KB |
testcase_38 | AC | 17 ms
11,212 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define llint long long using namespace std; llint h, w; llint a[405], b[405]; llint ans[405][405]; vector<llint> G[200005]; vector<int> topo; bool used[200005]; void tpsort(int v) { used[v] = true; for(int i = 0; i < G[v].size(); i++){ if(!used[G[v][i]]) tpsort(G[v][i]); } topo.push_back(v); } llint get(llint r, llint c) { return r * w + c; } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w; for(int i = 0; i < h; i++) cin >> a[i], a[i]--; for(int i = 0; i < w; i++) cin >> b[i], b[i]--; sort(a, a+h); sort(b, b+w); for(int i = 0; i < h; i++){ for(int j = a[i]-1; j >= 0; j--) G[get(i, j)].push_back(get(i, j+1)); for(int j = a[i]+1; j < w; j++) G[get(i, j)].push_back(get(i, j-1)); } for(int i = 0; i < w; i++){ for(int j = b[i]-1; j >= 0; j--) G[get(j, i)].push_back(get(j+1, i)); for(int j = b[i]+1; j < h; j++) G[get(j, i)].push_back(get(j-1, i)); } for(int i = 0; i < h*w; i++) if(!used[i]) tpsort(i); reverse(topo.begin(), topo.end()); for(int i = 0; i < topo.size(); i++){ int v = topo[i]; ans[v/w][v%w] = i+1; } for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ cout << ans[i][j] << " "; } cout << endl; } return 0; }