結果
問題 | No.918 LISGRID |
ユーザー | theory_and_me |
提出日時 | 2019-10-26 02:45:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,305 bytes |
コンパイル時間 | 1,809 ms |
コンパイル使用メモリ | 181,244 KB |
実行使用メモリ | 14,024 KB |
最終ジャッジ日時 | 2024-09-13 14:23:29 |
合計ジャッジ時間 | 8,106 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,812 KB |
testcase_01 | AC | 25 ms
9,856 KB |
testcase_02 | AC | 10 ms
6,944 KB |
testcase_03 | AC | 12 ms
6,944 KB |
testcase_04 | AC | 10 ms
6,944 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | AC | 25 ms
9,600 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,680 KB |
testcase_17 | AC | 18 ms
7,936 KB |
testcase_18 | AC | 16 ms
7,680 KB |
testcase_19 | AC | 7 ms
6,944 KB |
testcase_20 | AC | 22 ms
9,088 KB |
testcase_21 | AC | 8 ms
6,940 KB |
testcase_22 | AC | 6 ms
6,944 KB |
testcase_23 | AC | 14 ms
7,168 KB |
testcase_24 | AC | 3 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 3 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 3 ms
6,944 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 3 ms
6,940 KB |
testcase_34 | AC | 4 ms
6,948 KB |
testcase_35 | AC | 5 ms
6,940 KB |
testcase_36 | AC | 3 ms
6,940 KB |
testcase_37 | AC | 22 ms
9,088 KB |
testcase_38 | AC | 15 ms
7,296 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; }