結果

問題 No.1023 Cyclic Tour
ユーザー chocoruskchocorusk
提出日時 2020-03-07 23:18:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 844 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 54,744 KB
実行使用メモリ 18,016 KB
最終ジャッジ日時 2024-04-23 19:06:11
合計ジャッジ時間 8,216 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,520 KB
testcase_01 AC 3 ms
6,144 KB
testcase_02 AC 3 ms
6,016 KB
testcase_03 AC 3 ms
6,144 KB
testcase_04 AC 47 ms
12,800 KB
testcase_05 AC 49 ms
12,800 KB
testcase_06 AC 60 ms
16,640 KB
testcase_07 AC 54 ms
14,848 KB
testcase_08 AC 37 ms
10,112 KB
testcase_09 AC 35 ms
10,112 KB
testcase_10 AC 34 ms
9,984 KB
testcase_11 AC 45 ms
10,240 KB
testcase_12 AC 40 ms
9,856 KB
testcase_13 AC 38 ms
9,600 KB
testcase_14 AC 32 ms
9,600 KB
testcase_15 AC 38 ms
9,600 KB
testcase_16 AC 73 ms
14,592 KB
testcase_17 AC 73 ms
14,720 KB
testcase_18 AC 77 ms
15,808 KB
testcase_19 AC 75 ms
15,172 KB
testcase_20 AC 94 ms
13,744 KB
testcase_21 AC 92 ms
13,828 KB
testcase_22 AC 88 ms
13,380 KB
testcase_23 AC 88 ms
13,440 KB
testcase_24 AC 89 ms
13,000 KB
testcase_25 AC 76 ms
13,696 KB
testcase_26 AC 80 ms
14,124 KB
testcase_27 AC 77 ms
13,748 KB
testcase_28 AC 74 ms
12,928 KB
testcase_29 AC 67 ms
12,544 KB
testcase_30 AC 73 ms
13,056 KB
testcase_31 AC 65 ms
13,312 KB
testcase_32 AC 67 ms
14,848 KB
testcase_33 AC 72 ms
14,080 KB
testcase_34 AC 74 ms
13,440 KB
testcase_35 AC 92 ms
13,952 KB
testcase_36 AC 90 ms
13,696 KB
testcase_37 AC 66 ms
14,464 KB
testcase_38 AC 61 ms
13,184 KB
testcase_39 AC 85 ms
13,256 KB
testcase_40 AC 69 ms
13,184 KB
testcase_41 AC 72 ms
13,184 KB
testcase_42 AC 79 ms
14,020 KB
testcase_43 AC 65 ms
12,416 KB
testcase_44 AC 46 ms
11,392 KB
testcase_45 AC 41 ms
16,768 KB
testcase_46 AC 42 ms
16,768 KB
testcase_47 AC 51 ms
16,980 KB
testcase_48 TLE -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using P=pair<int, int>;
int n, m;
int a[200020], b[200020], c[200020];
vector<P> g[100010];
bool used[400040], finish[400040], ok;
void dfs(int x, int prev){
	for(auto p:g[x]){
        int y=p.first, i=p.second;
        if(finish[i] || abs(i-prev)==m) continue;
		if(used[i]) ok=1;
		else{
            used[i]=1;
            dfs(y, i);
        }
        finish[i]=1;
	}
}
int main()
{
    scanf("%d %d", &n, &m);
	for(int i=0; i<m; i++){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		a[i]--; b[i]--;
        g[a[i]].push_back({b[i], i});
        if(c[i]==1) g[b[i]].push_back({a[i], i+m});
	}
    for(int i=0; i<n; i++){
        dfs(i, 1000000007);
        if(ok){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}
0