結果
問題 | No.1023 Cyclic Tour |
ユーザー | ゆきのん |
提出日時 | 2020-04-15 18:15:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,369 bytes |
コンパイル時間 | 1,547 ms |
コンパイル使用メモリ | 167,784 KB |
実行使用メモリ | 14,720 KB |
最終ジャッジ日時 | 2024-04-09 18:55:34 |
合計ジャッジ時間 | 10,310 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,948 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | AC | 83 ms
9,856 KB |
testcase_05 | AC | 83 ms
9,856 KB |
testcase_06 | AC | 92 ms
10,112 KB |
testcase_07 | AC | 87 ms
10,240 KB |
testcase_08 | AC | 80 ms
9,216 KB |
testcase_09 | AC | 78 ms
9,216 KB |
testcase_10 | AC | 76 ms
9,088 KB |
testcase_11 | WA | - |
testcase_12 | AC | 77 ms
9,088 KB |
testcase_13 | AC | 76 ms
8,960 KB |
testcase_14 | WA | - |
testcase_15 | AC | 77 ms
8,832 KB |
testcase_16 | AC | 142 ms
9,556 KB |
testcase_17 | AC | 140 ms
9,740 KB |
testcase_18 | AC | 145 ms
9,728 KB |
testcase_19 | AC | 140 ms
9,588 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 151 ms
10,112 KB |
testcase_26 | AC | 154 ms
10,224 KB |
testcase_27 | AC | 142 ms
10,240 KB |
testcase_28 | AC | 150 ms
9,840 KB |
testcase_29 | AC | 146 ms
9,396 KB |
testcase_30 | AC | 151 ms
10,012 KB |
testcase_31 | AC | 144 ms
10,396 KB |
testcase_32 | AC | 146 ms
11,648 KB |
testcase_33 | AC | 152 ms
10,624 KB |
testcase_34 | AC | 146 ms
10,112 KB |
testcase_35 | AC | 160 ms
10,240 KB |
testcase_36 | WA | - |
testcase_37 | AC | 145 ms
10,624 KB |
testcase_38 | AC | 139 ms
10,288 KB |
testcase_39 | WA | - |
testcase_40 | AC | 147 ms
9,916 KB |
testcase_41 | AC | 165 ms
9,796 KB |
testcase_42 | AC | 169 ms
10,260 KB |
testcase_43 | AC | 138 ms
9,600 KB |
testcase_44 | AC | 81 ms
10,064 KB |
testcase_45 | AC | 82 ms
14,592 KB |
testcase_46 | AC | 78 ms
14,592 KB |
testcase_47 | AC | 86 ms
14,720 KB |
testcase_48 | WA | - |
testcase_49 | AC | 153 ms
10,552 KB |
testcase_50 | WA | - |
testcase_51 | AC | 155 ms
10,368 KB |
testcase_52 | AC | 155 ms
10,264 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long LL; typedef pair<LL,LL> P; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;} const LL mod=1000000007; const LL LINF=1LL<<62; const int INF=1<<30; int dx[]={1,0,-1,0,1,-1,1,-1}; int dy[]={0,1,0,-1,1,-1,-1,1}; vector<int> G[1<<17]; vector<int> vis(1<<17,0); bool dfs(int u,int v,int s){ if(vis[u]){ if(u == v || vis[u] < s + 1) return false; else return true; } vis[u] = s + 1; for(auto g:G[u]){ if(g == v) continue; if(dfs(g, u, s)) return true; } return false; } int main(){ int n,m;cin >> n >> m; for (int i = 0; i < m; i++) { int x,y,c;cin >> x >> y >> c; x--,y--; if(c == 1){ G[x].pb(y); G[y].pb(x); } else{ G[x].pb(y); } } bool ans = false; for (int i = 0; i < n; i++) { ans |= dfs(i,i,i); } if(ans) puts("Yes"); else puts("No"); return 0; }