結果

問題 No.1023 Cyclic Tour
ユーザー chocoruskchocorusk
提出日時 2020-03-07 23:09:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 54,880 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-04-23 19:05:37
合計ジャッジ時間 5,652 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,272 KB
testcase_01 WA -
testcase_02 AC 3 ms
6,144 KB
testcase_03 WA -
testcase_04 AC 42 ms
10,752 KB
testcase_05 AC 42 ms
10,624 KB
testcase_06 AC 44 ms
11,264 KB
testcase_07 AC 41 ms
11,008 KB
testcase_08 AC 35 ms
9,856 KB
testcase_09 AC 35 ms
9,728 KB
testcase_10 AC 34 ms
9,600 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 32 ms
9,088 KB
testcase_15 WA -
testcase_16 AC 63 ms
11,520 KB
testcase_17 AC 63 ms
11,776 KB
testcase_18 AC 66 ms
11,904 KB
testcase_19 AC 63 ms
11,776 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 73 ms
13,056 KB
testcase_26 AC 73 ms
12,928 KB
testcase_27 AC 69 ms
12,800 KB
testcase_28 AC 67 ms
12,160 KB
testcase_29 AC 63 ms
11,776 KB
testcase_30 AC 71 ms
12,416 KB
testcase_31 AC 65 ms
12,160 KB
testcase_32 AC 73 ms
11,904 KB
testcase_33 AC 72 ms
12,544 KB
testcase_34 AC 69 ms
12,672 KB
testcase_35 AC 75 ms
13,312 KB
testcase_36 WA -
testcase_37 AC 65 ms
12,288 KB
testcase_38 AC 64 ms
11,648 KB
testcase_39 WA -
testcase_40 AC 71 ms
12,416 KB
testcase_41 AC 66 ms
12,416 KB
testcase_42 AC 71 ms
13,312 KB
testcase_43 AC 59 ms
11,648 KB
testcase_44 AC 41 ms
10,624 KB
testcase_45 WA -
testcase_46 AC 34 ms
10,368 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 67 ms
12,000 KB
testcase_52 AC 69 ms
11,976 KB
権限があれば一括ダウンロードができます

ソースコード

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;
        used[i]=1;
		if(!finish[i]) ok=1;
		else 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