結果

問題 No.1023 Cyclic Tour
ユーザー chocoruskchocorusk
提出日時 2020-03-08 02:53:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,423 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 86,100 KB
実行使用メモリ 18,452 KB
最終ジャッジ日時 2024-04-23 19:07:41
合計ジャッジ時間 15,780 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,144 KB
testcase_01 AC 3 ms
6,144 KB
testcase_02 AC 3 ms
6,016 KB
testcase_03 AC 4 ms
6,144 KB
testcase_04 AC 46 ms
11,136 KB
testcase_05 AC 47 ms
11,200 KB
testcase_06 AC 52 ms
11,776 KB
testcase_07 AC 47 ms
11,392 KB
testcase_08 AC 41 ms
10,232 KB
testcase_09 AC 38 ms
10,136 KB
testcase_10 AC 37 ms
9,984 KB
testcase_11 AC 60 ms
10,496 KB
testcase_12 AC 52 ms
9,856 KB
testcase_13 AC 49 ms
9,600 KB
testcase_14 AC 41 ms
9,600 KB
testcase_15 AC 50 ms
9,848 KB
testcase_16 AC 65 ms
12,416 KB
testcase_17 AC 68 ms
12,260 KB
testcase_18 AC 72 ms
12,476 KB
testcase_19 AC 67 ms
12,032 KB
testcase_20 AC 150 ms
14,048 KB
testcase_21 AC 157 ms
14,080 KB
testcase_22 AC 127 ms
13,452 KB
testcase_23 AC 128 ms
13,440 KB
testcase_24 AC 110 ms
13,184 KB
testcase_25 AC 84 ms
13,952 KB
testcase_26 AC 83 ms
14,476 KB
testcase_27 AC 106 ms
13,956 KB
testcase_28 AC 82 ms
13,132 KB
testcase_29 AC 67 ms
12,672 KB
testcase_30 AC 76 ms
13,184 KB
testcase_31 AC 69 ms
13,440 KB
testcase_32 AC 73 ms
15,744 KB
testcase_33 AC 72 ms
14,336 KB
testcase_34 AC 78 ms
13,472 KB
testcase_35 AC 96 ms
13,952 KB
testcase_36 AC 139 ms
13,772 KB
testcase_37 AC 73 ms
14,896 KB
testcase_38 AC 69 ms
13,600 KB
testcase_39 AC 123 ms
13,568 KB
testcase_40 AC 72 ms
13,272 KB
testcase_41 AC 79 ms
13,184 KB
testcase_42 AC 78 ms
14,132 KB
testcase_43 AC 68 ms
12,484 KB
testcase_44 AC 50 ms
11,520 KB
testcase_45 AC 54 ms
16,660 KB
testcase_46 AC 48 ms
18,452 KB
testcase_47 AC 81 ms
18,176 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
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];
int ok;
chrono::system_clock::time_point start, ed;
void dfs(int x, int prev){
	for(auto p:g[x]){
        if(ok) return;
        ed = chrono::system_clock::now();
        double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(ed - start).count() / 1000.0);
        if(time>1900){
            ok=2;
            return;
        }
        int y=p.first, i=p.second;
        if(finish[i] || abs(i-prev)==m) continue;
		if(used[i]){
            ok=1;
            return;
		}else{
            used[i]=1;
            dfs(y, i);
        }
        finish[i]=1;
	}
}
int main()
{
    start = chrono::system_clock::now();
    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});
	}
    vector<int> ind(n);
    mt19937 mt(334);
    iota(ind.begin(), ind.end(), 0);
    shuffle(ind.begin(), ind.end(), mt);
    for(auto i:ind){
        dfs(i, 1000000007);
        if(ok==2){
            return 0;
        }
        if(ok){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}
0