結果

問題 No.1370 置換門松列
ユーザー 👑 NachiaNachia
提出日時 2021-01-30 20:50:04
言語 cLay
(20240104-1)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 4,470 ms
コンパイル使用メモリ 168,544 KB
実行使用メモリ 10,200 KB
最終ジャッジ日時 2023-10-12 21:05:30
合計ジャッジ時間 4,720 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,412 KB
testcase_01 AC 4 ms
7,428 KB
testcase_02 AC 4 ms
7,436 KB
testcase_03 AC 4 ms
7,460 KB
testcase_04 AC 4 ms
7,432 KB
testcase_05 AC 4 ms
7,436 KB
testcase_06 AC 4 ms
7,520 KB
testcase_07 AC 4 ms
7,428 KB
testcase_08 AC 4 ms
7,428 KB
testcase_09 AC 4 ms
7,436 KB
testcase_10 AC 4 ms
7,660 KB
testcase_11 AC 4 ms
7,424 KB
testcase_12 AC 4 ms
7,428 KB
testcase_13 AC 4 ms
7,436 KB
testcase_14 AC 4 ms
7,468 KB
testcase_15 AC 3 ms
7,432 KB
testcase_16 AC 3 ms
7,496 KB
testcase_17 AC 4 ms
7,696 KB
testcase_18 AC 3 ms
7,520 KB
testcase_19 AC 4 ms
7,408 KB
testcase_20 AC 4 ms
7,592 KB
testcase_21 AC 15 ms
10,116 KB
testcase_22 AC 10 ms
9,608 KB
testcase_23 AC 12 ms
9,420 KB
testcase_24 AC 6 ms
8,092 KB
testcase_25 AC 21 ms
10,200 KB
testcase_26 AC 21 ms
10,156 KB
testcase_27 AC 8 ms
9,064 KB
testcase_28 AC 8 ms
9,196 KB
testcase_29 AC 7 ms
8,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int N,M,A[1d5+1],I[1d5]={},ans[1d5];
VI E[1d5],V;

{
	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]].push_back(A[i]); I[A[i]]++; }
		else{ E[A[i]].push_back(A[i+1]); I[A[i+1]]++; }
	}
	queue<int> Q; rep(i,M) if(I[i]==0) Q.push(i);
	while(Q.size()){
		int p=Q.front(); Q.pop();
		V.push_back(p);
		for(int e:E[p]) if(0==--I[e]) Q.push(e);
	}
	if(V.size()!=M) wt("No"),exit(0);
	wt("Yes");
	rep(i,M) ans[V[i]]=i+1;
	wt(ans(M));
}
0