結果

問題 No.1370 置換門松列
ユーザー 👑 NachiaNachia
提出日時 2021-01-30 20:54:50
言語 cLay
(20240104-1)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 1,802 ms
コンパイル使用メモリ 165,152 KB
実行使用メモリ 10,380 KB
最終ジャッジ日時 2023-10-12 21:05:42
合計ジャッジ時間 3,702 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,532 KB
testcase_01 AC 3 ms
7,580 KB
testcase_02 AC 3 ms
7,464 KB
testcase_03 AC 3 ms
7,516 KB
testcase_04 AC 4 ms
7,416 KB
testcase_05 AC 4 ms
7,464 KB
testcase_06 AC 3 ms
7,516 KB
testcase_07 AC 3 ms
7,444 KB
testcase_08 AC 4 ms
7,496 KB
testcase_09 AC 3 ms
7,536 KB
testcase_10 AC 3 ms
7,412 KB
testcase_11 AC 4 ms
7,532 KB
testcase_12 AC 4 ms
7,420 KB
testcase_13 AC 4 ms
7,444 KB
testcase_14 AC 3 ms
7,484 KB
testcase_15 AC 4 ms
7,472 KB
testcase_16 AC 3 ms
7,516 KB
testcase_17 AC 4 ms
7,516 KB
testcase_18 AC 4 ms
7,500 KB
testcase_19 AC 3 ms
7,464 KB
testcase_20 AC 3 ms
7,412 KB
testcase_21 AC 15 ms
10,192 KB
testcase_22 AC 10 ms
9,484 KB
testcase_23 AC 12 ms
9,524 KB
testcase_24 AC 5 ms
8,028 KB
testcase_25 AC 20 ms
10,380 KB
testcase_26 AC 20 ms
10,288 KB
testcase_27 AC 8 ms
9,252 KB
testcase_28 AC 8 ms
9,120 KB
testcase_29 AC 6 ms
8,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define PB push_back
int N,M,A[1d5+1],I[1d5]={},ans[1d5],q=0;
VI E[1d5],V,Q;

{
	rd(N,M,A(N)--);
	rep(i,N-2) if(A[i]==A[i+2]) wt("No"),exit(0);
	rep(i,N-1){
		if(i%2) E[A[i+1]].PB(A[i]),I[A[i]]++;
		else E[A[i]].PB(A[i+1]),I[A[i+1]]++;
	}
	rep(i,M) if(I[i]==0) Q.PB(i);
	while(q<Q.size()){
		int p=Q[q++];
		V.PB(p);
		for(int e:E[p]) if(0==--I[e]) Q.PB(e);
	}
	if(V.size()!=M) wt("No"),exit(0);
	wt("Yes");
	rep(i,M) ans[V[i]]=i+1;
	wt(ans(M));
}
0