結果
問題 | No.1023 Cyclic Tour |
ユーザー | trineutron |
提出日時 | 2020-04-10 23:12:25 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 965 bytes |
コンパイル時間 | 2,159 ms |
コンパイル使用メモリ | 206,392 KB |
実行使用メモリ | 16,376 KB |
最終ジャッジ日時 | 2023-10-14 04:41:43 |
合計ジャッジ時間 | 16,121 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,704 KB |
testcase_01 | AC | 1 ms
4,352 KB |
testcase_02 | AC | 2 ms
4,352 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | WA | - |
testcase_05 | AC | 98 ms
9,096 KB |
testcase_06 | AC | 118 ms
10,752 KB |
testcase_07 | AC | 113 ms
10,156 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 113 ms
8,008 KB |
testcase_12 | AC | 103 ms
7,512 KB |
testcase_13 | AC | 92 ms
7,400 KB |
testcase_14 | AC | 83 ms
7,404 KB |
testcase_15 | AC | 99 ms
7,396 KB |
testcase_16 | AC | 172 ms
10,948 KB |
testcase_17 | WA | - |
testcase_18 | AC | 188 ms
12,156 KB |
testcase_19 | AC | 164 ms
9,160 KB |
testcase_20 | AC | 221 ms
10,048 KB |
testcase_21 | AC | 220 ms
10,172 KB |
testcase_22 | AC | 209 ms
9,756 KB |
testcase_23 | AC | 213 ms
9,704 KB |
testcase_24 | AC | 208 ms
9,368 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 188 ms
9,240 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 174 ms
9,892 KB |
testcase_32 | AC | 178 ms
12,040 KB |
testcase_33 | AC | 185 ms
10,424 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 220 ms
9,860 KB |
testcase_37 | AC | 178 ms
11,224 KB |
testcase_38 | AC | 165 ms
9,592 KB |
testcase_39 | AC | 211 ms
9,512 KB |
testcase_40 | AC | 182 ms
9,492 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 105 ms
16,240 KB |
testcase_46 | AC | 101 ms
16,376 KB |
testcase_47 | AC | 115 ms
16,244 KB |
testcase_48 | AC | 555 ms
9,252 KB |
testcase_49 | TLE | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using graph = vector<vector<pair<int, int>>>; bool dfs(const graph &to, vector<bool> &visited, int city, int road, int term) { visited.at(road) = true; for (auto next : to.at(city)) { if (next.second == road) continue; if (next.first == term) return true; if (visited.at(next.second)) continue; if (dfs(to, visited, next.first, next.second, term)) return true; } return false; } int main() { int n, m; cin >> n >> m; graph to(n); for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; a--; b--; to.at(a).emplace_back(b, i); if (c == 1) { to.at(b).emplace_back(a, i); } } vector<bool> visited(m + 1); for (int i = 0; i < n; i++) { if (dfs(to, visited, i, m, i)) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; }