結果

問題 No.1023 Cyclic Tour
ユーザー chocoruskchocorusk
提出日時 2020-03-07 23:17:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 54,872 KB
実行使用メモリ 17,892 KB
最終ジャッジ日時 2024-04-23 19:06:21
合計ジャッジ時間 8,186 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,520 KB
testcase_01 AC 3 ms
6,144 KB
testcase_02 AC 3 ms
6,144 KB
testcase_03 AC 3 ms
6,016 KB
testcase_04 AC 48 ms
12,288 KB
testcase_05 AC 47 ms
12,416 KB
testcase_06 AC 60 ms
14,976 KB
testcase_07 AC 54 ms
13,696 KB
testcase_08 AC 36 ms
10,112 KB
testcase_09 AC 37 ms
9,984 KB
testcase_10 AC 37 ms
9,984 KB
testcase_11 AC 47 ms
10,240 KB
testcase_12 AC 39 ms
9,856 KB
testcase_13 AC 37 ms
9,600 KB
testcase_14 AC 35 ms
9,472 KB
testcase_15 AC 39 ms
9,728 KB
testcase_16 AC 72 ms
14,208 KB
testcase_17 AC 77 ms
14,592 KB
testcase_18 AC 78 ms
15,616 KB
testcase_19 AC 72 ms
14,976 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 86 ms
13,184 KB
testcase_24 AC 81 ms
12,928 KB
testcase_25 AC 75 ms
13,568 KB
testcase_26 AC 71 ms
13,440 KB
testcase_27 AC 67 ms
13,312 KB
testcase_28 AC 71 ms
12,800 KB
testcase_29 AC 65 ms
12,288 KB
testcase_30 AC 67 ms
13,056 KB
testcase_31 AC 63 ms
12,800 KB
testcase_32 AC 66 ms
12,672 KB
testcase_33 AC 69 ms
13,056 KB
testcase_34 AC 74 ms
13,184 KB
testcase_35 AC 83 ms
13,824 KB
testcase_36 WA -
testcase_37 AC 68 ms
12,800 KB
testcase_38 AC 62 ms
12,288 KB
testcase_39 WA -
testcase_40 AC 74 ms
12,928 KB
testcase_41 AC 74 ms
13,056 KB
testcase_42 AC 80 ms
13,696 KB
testcase_43 AC 67 ms
12,160 KB
testcase_44 AC 46 ms
11,520 KB
testcase_45 AC 43 ms
16,768 KB
testcase_46 AC 43 ms
16,768 KB
testcase_47 AC 52 ms
17,024 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)==n) 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+n});
	}
    for(int i=0; i<n; i++){
        dfs(i, -1);
        if(ok){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}
0