結果

問題 No.1508 Avoid being hit
ユーザー HaaHaa
提出日時 2021-05-14 23:47:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,564 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 169,792 KB
実行使用メモリ 7,116 KB
最終ジャッジ日時 2024-04-10 04:37:35
合計ジャッジ時間 7,190 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 WA -
testcase_16 AC 38 ms
6,944 KB
testcase_17 AC 21 ms
6,944 KB
testcase_18 AC 21 ms
6,940 KB
testcase_19 AC 34 ms
6,940 KB
testcase_20 AC 54 ms
6,944 KB
testcase_21 AC 35 ms
6,940 KB
testcase_22 AC 42 ms
6,940 KB
testcase_23 AC 45 ms
6,940 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
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 WA -
testcase_45 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    int n, q; cin >> n >> q;
    VI a(q), b(q);
    REP(i,q) cin >> a[i], a[i]--;
    REP(i,q) cin >> b[i], b[i]--;

    int l=-1, r=n;
    VI x(q), y(q);
    for(int i=q-1;i>=0;i--){
        if(a[i]>b[i]) swap(a[i],b[i]);
        if(l+1==a[i]&&a[i]+1==b[i])
            l++;
        else if(l==a[i]&&a[i]+1==b[i])
            l+=0;
        else
            l=max(l-1,-1);
        if(r-1==b[i]&&a[i]+1==b[i])
            r--;
        else if(r==b[i]&&a[i]+1==b[i])
            r+=0;
        else
            r=min(r+1,n);
        x[i]=l;
        y[i]=r;
    }
    VI ans;
    int now=x[0]+2;
    ans.push_back(now);
    bool no=0;
    REP(i,q){
        int p=-1;
        for(int j=-1;j<=1;j++){
            bool ok=1;
            if(i<q-2&&(now+j>=y[i+1]||now+j<=x[i+1]||now+j>=n||now+j<0))
                ok=0;
            if(now+j==a[i])
                ok=0;
            if(now+j==b[i])
                ok=0;
            if(ok){
                p=now+j;
                break;
            }
        }
        now=p;
        if(now==-1){
            no=1;
            break;
        }
        ans.push_back(now);
    }
    if(no){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
        REP(i,q+1){
            cout << ans[i]+1 << endl;
        }
    }
}
0