結果
問題 | No.1647 Travel in Mitaru city 2 |
ユーザー | kwm_t |
提出日時 | 2021-08-13 23:09:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,151 bytes |
コンパイル時間 | 4,397 ms |
コンパイル使用メモリ | 238,068 KB |
実行使用メモリ | 69,796 KB |
最終ジャッジ日時 | 2024-04-21 04:57:21 |
合計ジャッジ時間 | 23,556 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
8,168 KB |
testcase_01 | AC | 5 ms
8,192 KB |
testcase_02 | AC | 4 ms
8,192 KB |
testcase_03 | AC | 4 ms
8,576 KB |
testcase_04 | AC | 16 ms
12,684 KB |
testcase_05 | AC | 5 ms
8,312 KB |
testcase_06 | AC | 5 ms
8,420 KB |
testcase_07 | AC | 27 ms
17,164 KB |
testcase_08 | AC | 425 ms
51,856 KB |
testcase_09 | AC | 359 ms
54,072 KB |
testcase_10 | AC | 378 ms
52,512 KB |
testcase_11 | AC | 356 ms
52,828 KB |
testcase_12 | AC | 391 ms
67,772 KB |
testcase_13 | AC | 386 ms
66,480 KB |
testcase_14 | AC | 381 ms
53,648 KB |
testcase_15 | AC | 380 ms
53,004 KB |
testcase_16 | AC | 348 ms
50,096 KB |
testcase_17 | AC | 362 ms
63,024 KB |
testcase_18 | AC | 389 ms
69,020 KB |
testcase_19 | AC | 401 ms
67,844 KB |
testcase_20 | AC | 405 ms
69,332 KB |
testcase_21 | AC | 402 ms
69,796 KB |
testcase_22 | AC | 401 ms
54,272 KB |
testcase_23 | AC | 400 ms
54,608 KB |
testcase_24 | AC | 404 ms
69,756 KB |
testcase_25 | AC | 402 ms
69,468 KB |
testcase_26 | AC | 392 ms
54,740 KB |
testcase_27 | AC | 384 ms
54,968 KB |
testcase_28 | AC | 398 ms
55,816 KB |
testcase_29 | AC | 382 ms
56,068 KB |
testcase_30 | AC | 397 ms
68,364 KB |
testcase_31 | AC | 383 ms
55,944 KB |
testcase_32 | AC | 396 ms
66,440 KB |
testcase_33 | AC | 379 ms
65,032 KB |
testcase_34 | AC | 389 ms
55,944 KB |
testcase_35 | AC | 385 ms
62,860 KB |
testcase_36 | AC | 399 ms
55,812 KB |
testcase_37 | AC | 393 ms
55,812 KB |
testcase_38 | AC | 385 ms
50,424 KB |
testcase_39 | AC | 389 ms
58,224 KB |
testcase_40 | AC | 401 ms
50,300 KB |
testcase_41 | AC | 397 ms
57,844 KB |
testcase_42 | AC | 408 ms
50,244 KB |
testcase_43 | AC | 5 ms
8,320 KB |
testcase_44 | AC | 5 ms
8,192 KB |
testcase_45 | AC | 343 ms
48,028 KB |
testcase_46 | AC | 338 ms
47,936 KB |
testcase_47 | AC | 332 ms
48,072 KB |
testcase_48 | AC | 338 ms
48,064 KB |
testcase_49 | AC | 342 ms
48,084 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[100005]; bool b; vector<int>ans; void dfs(int v, int root, int p = -1) { use[v / 2] = true; for (auto e : to[v]) { if (root == e / 2) b = true; if (b)break; if (use[e / 2])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)use[j] = true; rep(j, scc[i].size())use[scc[i][j] / 2] = false; ans.push_back(fir); dfs(fir, fir / 2); cout << ans.size() << endl; rep(j, ans.size()) cout << ans[j] / 2 + 1 << " "; return 0; } cout << -1 << endl; return 0; }