結果

問題 No.1023 Cyclic Tour
ユーザー tailstails
提出日時 2020-11-13 10:22:31
言語 cLay
(20240104-1)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 5,379 ms
コンパイル使用メモリ 211,272 KB
実行使用メモリ 15,304 KB
最終ジャッジ日時 2023-09-19 01:49:36
合計ジャッジ時間 14,395 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,056 KB
testcase_01 AC 2 ms
5,064 KB
testcase_02 AC 2 ms
4,992 KB
testcase_03 AC 1 ms
5,060 KB
testcase_04 AC 21 ms
8,868 KB
testcase_05 AC 21 ms
8,948 KB
testcase_06 AC 23 ms
9,104 KB
testcase_07 AC 22 ms
8,988 KB
testcase_08 AC 21 ms
9,332 KB
testcase_09 AC 21 ms
9,172 KB
testcase_10 AC 21 ms
9,300 KB
testcase_11 AC 26 ms
9,744 KB
testcase_12 AC 23 ms
9,496 KB
testcase_13 AC 22 ms
9,408 KB
testcase_14 AC 20 ms
9,148 KB
testcase_15 AC 24 ms
9,196 KB
testcase_16 AC 36 ms
10,924 KB
testcase_17 AC 37 ms
10,892 KB
testcase_18 AC 38 ms
11,008 KB
testcase_19 AC 37 ms
10,596 KB
testcase_20 AC 41 ms
10,400 KB
testcase_21 AC 44 ms
10,512 KB
testcase_22 AC 40 ms
10,600 KB
testcase_23 AC 42 ms
10,844 KB
testcase_24 AC 44 ms
11,472 KB
testcase_25 AC 41 ms
10,200 KB
testcase_26 AC 43 ms
10,188 KB
testcase_27 AC 42 ms
10,072 KB
testcase_28 AC 41 ms
11,076 KB
testcase_29 AC 39 ms
10,728 KB
testcase_30 AC 41 ms
11,424 KB
testcase_31 AC 39 ms
11,212 KB
testcase_32 AC 41 ms
12,332 KB
testcase_33 AC 42 ms
11,700 KB
testcase_34 AC 37 ms
9,816 KB
testcase_35 AC 39 ms
9,860 KB
testcase_36 AC 42 ms
10,368 KB
testcase_37 AC 39 ms
11,836 KB
testcase_38 AC 38 ms
11,272 KB
testcase_39 AC 42 ms
10,668 KB
testcase_40 AC 40 ms
10,792 KB
testcase_41 AC 40 ms
10,964 KB
testcase_42 AC 44 ms
10,576 KB
testcase_43 AC 39 ms
10,796 KB
testcase_44 AC 25 ms
8,728 KB
testcase_45 AC 29 ms
14,736 KB
testcase_46 AC 28 ms
14,800 KB
testcase_47 AC 34 ms
15,304 KB
testcase_48 AC 38 ms
10,952 KB
testcase_49 AC 37 ms
10,952 KB
testcase_50 AC 38 ms
10,684 KB
testcase_51 AC 39 ms
10,696 KB
testcase_52 AC 38 ms
10,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

graph g;
#define MAXN 100001
int gr[MAXN];
char vis[MAXN];

void f1(int i,int p,int r){
	if(gr[i]){
		wt("Yes");
		exit(0);
	}
	gr[i]=r;
	rep[g.edge[i]](j,g.es[i]){
		if(j!=p){
			f1(j,i,r);
		}
	}
}

void f2(int i){
	if(vis[i]){
		if(vis[i]==1){
			wt("Yes");
			exit(0);
		}
	}else{
		vis[i]=1;
		rep[g.edge[i]](j,g.es[i]){
			f2(j);
		}
		vis[i]=2;
	}
}

int a[2d5],b[2d5],c[2d5];
{
	int @n,@m;
	rd((a,b,c)(m));
	sortA(m,c,a,b);
	int h=2m-sum(c(m));
	g.setEdge(n+1,h,a,b);
	int r=1;
	for(int i=1;i<=n;++i){
		if(!gr[i]){
			f1(i,0,r++);
		}
	}
	for(int j=h;j<m;++j){
		a[j]=gr[a[j]];
		b[j]=gr[b[j]];
	}
	g.setDirectEdge(r,m-h,a+h,b+h);
	for(int i=0;i<r;++i){
		f2(i);
	}
	wt("No");
}
0