結果
問題 | No.1647 Travel in Mitaru city 2 |
ユーザー | kwm_t |
提出日時 | 2021-08-13 22:54:36 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,135 bytes |
コンパイル時間 | 4,588 ms |
コンパイル使用メモリ | 238,960 KB |
実行使用メモリ | 70,048 KB |
最終ジャッジ日時 | 2024-04-14 19:44:38 |
合計ジャッジ時間 | 27,839 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
8,208 KB |
testcase_01 | AC | 4 ms
8,240 KB |
testcase_02 | AC | 4 ms
8,124 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 408 ms
51,852 KB |
testcase_09 | AC | 389 ms
54,192 KB |
testcase_10 | AC | 413 ms
52,640 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 434 ms
53,900 KB |
testcase_15 | AC | 400 ms
53,252 KB |
testcase_16 | AC | 365 ms
50,128 KB |
testcase_17 | WA | - |
testcase_18 | AC | 458 ms
69,148 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 453 ms
54,396 KB |
testcase_23 | AC | 443 ms
54,796 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 451 ms
54,968 KB |
testcase_27 | AC | 438 ms
55,092 KB |
testcase_28 | AC | 440 ms
55,812 KB |
testcase_29 | AC | 429 ms
55,816 KB |
testcase_30 | WA | - |
testcase_31 | AC | 446 ms
55,944 KB |
testcase_32 | AC | 443 ms
66,440 KB |
testcase_33 | AC | 426 ms
65,160 KB |
testcase_34 | AC | 431 ms
55,812 KB |
testcase_35 | AC | 427 ms
62,976 KB |
testcase_36 | AC | 458 ms
56,068 KB |
testcase_37 | AC | 445 ms
55,940 KB |
testcase_38 | AC | 444 ms
50,796 KB |
testcase_39 | WA | - |
testcase_40 | AC | 453 ms
50,452 KB |
testcase_41 | WA | - |
testcase_42 | AC | 437 ms
50,700 KB |
testcase_43 | AC | 4 ms
8,208 KB |
testcase_44 | AC | 5 ms
8,272 KB |
testcase_45 | AC | 368 ms
48,292 KB |
testcase_46 | AC | 379 ms
47,984 KB |
testcase_47 | AC | 362 ms
48,184 KB |
testcase_48 | AC | 371 ms
48,288 KB |
testcase_49 | AC | 393 ms
48,148 KB |
testcase_50 | WA | - |
ソースコード
#include "bits/stdc++.h" #include "atcoder/all" using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; //const bool debug = false; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } vector<int>to[200005]; bool use[200005]; bool b; vector<int>ans; void dfs(int v, int root, int p = -1) { use[v] = true; for (auto e : to[v]) { if (root == e) b = true; if (b)break; if (use[e])continue; ans.push_back(e); dfs(e, root, v); if (b)break; ans.pop_back(); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h, w, n; cin >> h >> w >> n; map<int, set<int>>mpx, mpy; vector<int>x(n), y(n); rep(i, n) { cin >> x[i] >> y[i]; x[i]--; y[i]--; mpx[x[i]].insert(i); mpy[y[i]].insert(i); } scc_graph ss(2 * n); rep(i, n) { for (auto idx : mpy[y[i]]) { if (i == idx) continue; to[i * 2].push_back(idx * 2 + 1); ss.add_edge(i * 2, idx * 2 + 1); } for (auto idx : mpx[x[i]]) { if (i == idx) continue; to[i * 2 + 1].push_back(idx * 2); ss.add_edge(i * 2 + 1, idx * 2); } } vector<vector<int>> scc = ss.scc(); rep(i, scc.size()) { if (4 > scc[i].size())continue; int fir = -1; rep(j, scc[i].size()) { if (0 == scc[i][j] % 2)fir = scc[i][j]; } rep(j, n * 2)use[j] = true; rep(j, scc[i].size())use[scc[i][j]] = false; ans.push_back(fir); dfs(fir, fir); cout << ans.size() << endl; rep(j, ans.size()) cout << ans[j] / 2 + 1 << " "; return 0; } cout << -1 << endl; return 0; }