結果
問題 | No.1023 Cyclic Tour |
ユーザー | trineutron |
提出日時 | 2020-04-10 23:16:24 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 922 bytes |
コンパイル時間 | 2,056 ms |
コンパイル使用メモリ | 206,684 KB |
実行使用メモリ | 14,684 KB |
最終ジャッジ日時 | 2023-10-14 05:00:11 |
合計ジャッジ時間 | 14,913 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
4,348 KB |
testcase_02 | AC | 1 ms
4,352 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | WA | - |
testcase_05 | AC | 100 ms
9,148 KB |
testcase_06 | AC | 109 ms
10,516 KB |
testcase_07 | AC | 94 ms
9,876 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 98 ms
8,084 KB |
testcase_12 | AC | 88 ms
7,508 KB |
testcase_13 | AC | 86 ms
7,256 KB |
testcase_14 | AC | 77 ms
7,196 KB |
testcase_15 | AC | 86 ms
7,368 KB |
testcase_16 | AC | 148 ms
10,468 KB |
testcase_17 | WA | - |
testcase_18 | AC | 167 ms
11,444 KB |
testcase_19 | AC | 147 ms
8,892 KB |
testcase_20 | AC | 190 ms
10,248 KB |
testcase_21 | AC | 197 ms
10,404 KB |
testcase_22 | AC | 176 ms
9,568 KB |
testcase_23 | AC | 188 ms
9,744 KB |
testcase_24 | AC | 170 ms
9,416 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 162 ms
9,040 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 159 ms
9,744 KB |
testcase_32 | AC | 164 ms
11,180 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 177 ms
9,888 KB |
testcase_37 | WA | - |
testcase_38 | AC | 155 ms
9,320 KB |
testcase_39 | AC | 187 ms
9,304 KB |
testcase_40 | AC | 160 ms
9,432 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 95 ms
14,684 KB |
testcase_46 | AC | 89 ms
14,620 KB |
testcase_47 | AC | 103 ms
14,600 KB |
testcase_48 | AC | 649 ms
9,272 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 (visited.at(next.second)) continue; if (next.first == term) return true; 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; }