結果

問題 No.1508 Avoid being hit
ユーザー chocoruskchocorusk
提出日時 2021-05-15 00:02:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,646 bytes
コンパイル時間 4,004 ms
コンパイル使用メモリ 195,844 KB
実行使用メモリ 155,492 KB
最終ジャッジ日時 2023-07-25 12:27:51
合計ジャッジ時間 16,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 578 ms
155,492 KB
testcase_01 AC 4 ms
8,088 KB
testcase_02 AC 4 ms
8,232 KB
testcase_03 AC 4 ms
8,144 KB
testcase_04 AC 5 ms
8,384 KB
testcase_05 AC 4 ms
8,216 KB
testcase_06 WA -
testcase_07 AC 4 ms
8,104 KB
testcase_08 AC 4 ms
8,096 KB
testcase_09 AC 4 ms
8,152 KB
testcase_10 WA -
testcase_11 AC 4 ms
8,168 KB
testcase_12 AC 4 ms
8,228 KB
testcase_13 AC 4 ms
8,160 KB
testcase_14 AC 4 ms
8,096 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 267 ms
45,928 KB
testcase_25 AC 247 ms
42,800 KB
testcase_26 AC 21 ms
10,692 KB
testcase_27 AC 126 ms
25,680 KB
testcase_28 AC 127 ms
25,784 KB
testcase_29 AC 249 ms
43,268 KB
testcase_30 AC 134 ms
26,980 KB
testcase_31 AC 221 ms
38,988 KB
testcase_32 AC 236 ms
41,380 KB
testcase_33 AC 67 ms
17,120 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 4 ms
8,100 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
map<int, int> pr[100010];
int main()
{
    int n, q; cin>>n>>q;
	int a[100010], b[100010];
	for(int i=0; i<q; i++){
		cin>>a[i]; a[i]--;
	}
	for(int i=0; i<q; i++){
		cin>>b[i]; b[i]--;
	}
    for(int i=-20; i<=20; i++){
        int x=a[0]+i;
        if(x>=0 && x<n) pr[0][x]=0;
    }
    for(int i=0; i<q; i++){
        for(auto p:pr[i]){
            int x=p.first;
            for(int k=-1; k<=1; k++){
                int y=x+k;
                if(y<0 || y>=n) continue;
                int d1=abs(y-a[i]), d2=abs(y-b[i]);
                if(d1>0 && d2>0 && (d1<=20 || d2<=20)){
                    pr[i+1][y]=x;
                }
            }
        }
    }
    if(pr[q].empty()){
        mt19937 mt(334);
        uniform_int_distribution rndn(0, n-1);
        {
            for(int l=0; l<50; l++){
                int s=rndn(mt);
                vector<int> ans;
                bool dame=0;
                ans.push_back(s+1);
                for(int i=0; i<q; i++){
                    vector<int> v;
                    if(s-1>=0 && a[i]!=s-1 && b[i]!=s-1){
                        v.push_back(s-1);
                    }
                    if(a[i]!=s && b[i]!=s){
                        v.push_back(s);
                    }
                    if(s+1<n && a[i]!=s+1 && b[i]!=s+1){
                        v.push_back(s+1);
                    }
                    if(v.empty()){
                        dame=1;break;
                    }
                    ans.push_back(v[mt()%((int)v.size())]+1);
                }
                if(!dame){
                    cout<<"YES"<<endl;
                    for(auto x:ans) cout<<x<<endl;
                    return 0;
                }
            }
            cout<<"NO"<<endl;
            return 0;
        }
        return 0;
    }
    cout<<"YES"<<endl;
    int x=pr[q].begin()->first;
    vector<int> ans;
    for(int i=q; i>=0; i--){
        ans.push_back(x);
        x=pr[i][x];
    }
    reverse(ans.begin(), ans.end());
    for(auto y:ans) cout<<y+1<<endl;
    return 0;
}
0