結果

問題 No.1508 Avoid being hit
ユーザー 沙耶花沙耶花
提出日時 2021-05-14 22:43:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,068 bytes
コンパイル時間 4,317 ms
コンパイル使用メモリ 261,620 KB
実行使用メモリ 45,348 KB
最終ジャッジ日時 2024-04-10 05:33:14
合計ジャッジ時間 11,129 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 94 ms
25,760 KB
testcase_17 AC 51 ms
15,616 KB
testcase_18 AC 58 ms
17,792 KB
testcase_19 AC 73 ms
20,736 KB
testcase_20 AC 147 ms
39,384 KB
testcase_21 AC 93 ms
26,292 KB
testcase_22 AC 116 ms
31,744 KB
testcase_23 AC 134 ms
35,720 KB
testcase_24 AC 259 ms
45,348 KB
testcase_25 AC 238 ms
41,884 KB
testcase_26 AC 19 ms
6,944 KB
testcase_27 AC 119 ms
22,912 KB
testcase_28 AC 119 ms
23,168 KB
testcase_29 AC 237 ms
42,464 KB
testcase_30 AC 131 ms
24,452 KB
testcase_31 AC 216 ms
37,632 KB
testcase_32 AC 246 ms
40,636 KB
testcase_33 AC 69 ms
13,312 KB
testcase_34 AC 210 ms
33,760 KB
testcase_35 AC 43 ms
8,396 KB
testcase_36 AC 131 ms
20,352 KB
testcase_37 AC 69 ms
10,752 KB
testcase_38 AC 173 ms
27,688 KB
testcase_39 AC 121 ms
19,072 KB
testcase_40 AC 222 ms
35,200 KB
testcase_41 AC 143 ms
21,376 KB
testcase_42 AC 223 ms
35,328 KB
testcase_43 AC 261 ms
40,788 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 AC 1 ms
6,940 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