結果
問題 | No.918 LISGRID |
ユーザー | theory_and_me |
提出日時 | 2019-10-26 02:45:22 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,305 bytes |
コンパイル時間 | 3,496 ms |
コンパイル使用メモリ | 176,548 KB |
実行使用メモリ | 14,176 KB |
最終ジャッジ日時 | 2023-10-11 15:35:44 |
合計ジャッジ時間 | 9,384 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,352 KB |
testcase_01 | AC | 30 ms
9,700 KB |
testcase_02 | AC | 10 ms
5,608 KB |
testcase_03 | AC | 14 ms
6,840 KB |
testcase_04 | AC | 10 ms
5,952 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | AC | 27 ms
9,360 KB |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | AC | 17 ms
7,456 KB |
testcase_17 | AC | 19 ms
7,868 KB |
testcase_18 | AC | 18 ms
7,456 KB |
testcase_19 | AC | 7 ms
5,108 KB |
testcase_20 | AC | 25 ms
9,092 KB |
testcase_21 | AC | 8 ms
5,368 KB |
testcase_22 | AC | 6 ms
4,808 KB |
testcase_23 | AC | 14 ms
6,932 KB |
testcase_24 | AC | 3 ms
4,352 KB |
testcase_25 | AC | 2 ms
4,352 KB |
testcase_26 | AC | 2 ms
4,348 KB |
testcase_27 | AC | 2 ms
4,348 KB |
testcase_28 | AC | 2 ms
4,348 KB |
testcase_29 | AC | 2 ms
4,348 KB |
testcase_30 | AC | 2 ms
4,348 KB |
testcase_31 | AC | 2 ms
4,352 KB |
testcase_32 | AC | 2 ms
4,352 KB |
testcase_33 | AC | 2 ms
4,352 KB |
testcase_34 | AC | 3 ms
4,348 KB |
testcase_35 | AC | 5 ms
4,352 KB |
testcase_36 | AC | 2 ms
4,352 KB |
testcase_37 | AC | 24 ms
8,784 KB |
testcase_38 | AC | 16 ms
7,248 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i,n) for(int i=0;i<(int)n;++i) //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){ os << "(" << v.first << ", " << v.second << ")"; return os; } template<class T> ostream& operator << (ostream& os, const vector<T> v){ for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){ for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } typedef vector<ll> Edges; typedef vector<Edges> Graph; const ll V_MAX = 101010; // !! SHOULD BE EDITTED !! vector<ll> ts(V_MAX, -1); bool topologicalSort(Graph &G){ ll V = G.size(); vector<ll> indeg(V, 0); queue<ll> qu; REP(i, V){ REP(j, G[i].size()){ indeg[G[i][j]]++; } } REP(i, V){ if(!indeg[i]) qu.push(i); } ll idx = 0; while(!qu.empty()){ ll s = qu.size(); REP(i, s){ ll now = qu.front();qu.pop(); ts[now] = idx; idx++; REP(j, G[now].size()){ ll next = G[now][j]; indeg[next]--; if(!indeg[next]) qu.push(next); } } } return (idx == V); } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll H, W; cin >> H >> W; vector<ll> A(H), B(W); REP(i, H) cin >> A[i]; REP(j, W) cin >> B[j]; sort(A.begin(), A.end()); sort(B.begin(), B.end()); Graph G(H*W); REP(i, H){ REP(j, W-1){ if(j<A[i]-1) G[W*i+j].push_back(W*i+j+1); else G[W*i+j+1].push_back(W*i+j); } } REP(j, W){ REP(i, H-1){ if(i<B[j]-1) G[W*i+j].push_back(W*i+j+W); else G[W*i+j+W].push_back(W*i+j); } } topologicalSort(G); /* REP(i, H*W){ dump(i) REP(j, G[i].size()){ cout << G[i][j] << " "; } cout << endl; } */ REP(i, H){ REP(j, W){ cout << ts[W*i+j]+1 << " "; } cout << endl; } return 0; }