結果

問題 No.1508 Avoid being hit
ユーザー 沙耶花沙耶花
提出日時 2021-05-14 22:43:19
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,068 bytes
コンパイル時間 3,442 ms
使用メモリ 45,328 KB
最終ジャッジ日時 2022-11-26 01:00:32
合計ジャッジ時間 10,147 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
3,572 KB
testcase_02 AC 1 ms
3,412 KB
testcase_03 AC 1 ms
3,524 KB
testcase_04 AC 1 ms
3,408 KB
testcase_05 AC 1 ms
3,416 KB
testcase_06 AC 1 ms
3,480 KB
testcase_07 AC 1 ms
3,548 KB
testcase_08 AC 1 ms
3,488 KB
testcase_09 AC 1 ms
3,540 KB
testcase_10 AC 1 ms
3,472 KB
testcase_11 AC 1 ms
3,516 KB
testcase_12 AC 1 ms
3,564 KB
testcase_13 AC 1 ms
3,420 KB
testcase_14 AC 2 ms
3,412 KB
testcase_15 AC 1 ms
3,524 KB
testcase_16 AC 80 ms
25,792 KB
testcase_17 AC 43 ms
15,540 KB
testcase_18 AC 50 ms
17,640 KB
testcase_19 AC 60 ms
20,564 KB
testcase_20 AC 126 ms
39,312 KB
testcase_21 AC 92 ms
26,148 KB
testcase_22 AC 100 ms
31,324 KB
testcase_23 AC 115 ms
35,616 KB
testcase_24 AC 222 ms
45,328 KB
testcase_25 AC 208 ms
41,832 KB
testcase_26 AC 15 ms
5,876 KB
testcase_27 AC 106 ms
22,588 KB
testcase_28 AC 105 ms
22,848 KB
testcase_29 AC 206 ms
42,396 KB
testcase_30 AC 108 ms
24,336 KB
testcase_31 AC 184 ms
37,556 KB
testcase_32 AC 208 ms
40,456 KB
testcase_33 AC 54 ms
13,328 KB
testcase_34 AC 179 ms
33,512 KB
testcase_35 AC 37 ms
8,276 KB
testcase_36 AC 108 ms
20,260 KB
testcase_37 AC 59 ms
10,784 KB
testcase_38 AC 153 ms
27,468 KB
testcase_39 AC 103 ms
18,984 KB
testcase_40 AC 191 ms
34,936 KB
testcase_41 AC 113 ms
21,404 KB
testcase_42 AC 186 ms
35,244 KB
testcase_43 AC 221 ms
40,560 KB
testcase_44 AC 1 ms
3,420 KB
testcase_45 AC 1 ms
3,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<int> A(Q),B(Q);
	rep(i,Q){
		cin>>A[i];
		A[i]--;
	}
	
	rep(i,Q){
		cin>>B[i];
		B[i]--;
	}
	
	vector<set<int>> S(Q+1);
	
	rep(i,N){
		S[0].insert(i);
	}
	
	
	rep(i,Q){
		while(S[i].size()>8){
			S[i].erase(S[i].begin());
		}
		for(auto a:S[i]){
			S[i+1].insert(max(0,a-1));
			S[i+1].insert(a);
			S[i+1].insert(min(N-1,a+1));
		}
		
		S[i+1].erase(A[i]);
		S[i+1].erase(B[i]);
		if(S[i+1].size()==0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	
	cout<<"YES"<<endl;
	
	vector<int> ans;
	for(int i=Q;i>=0;i--){
		if(i==Q){
			ans.push_back(*(S[i].begin()));
		}
		else{
			int c = ans.back();
			for(int j=-1;j<=1;j++){
				if(S[i].count(c+j)){
					ans.push_back(c+j);
					break;
				}
			}
			
		}
	}
	
	reverse(ans.begin(),ans.end());
	
	rep(i,ans.size()){
		cout<<ans[i]+1<<endl;
	}
		
	
    return 0;
}
0