結果

問題 No.1508 Avoid being hit
ユーザー どららどらら
提出日時 2021-05-14 23:32:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,990 bytes
コンパイル時間 4,096 ms
コンパイル使用メモリ 227,320 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 04:06:34
合計ジャッジ時間 8,731 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 38 ms
6,940 KB
testcase_17 AC 23 ms
6,940 KB
testcase_18 AC 20 ms
6,944 KB
testcase_19 AC 33 ms
6,944 KB
testcase_20 AC 55 ms
6,940 KB
testcase_21 AC 36 ms
6,940 KB
testcase_22 AC 41 ms
6,944 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 AC 130 ms
6,944 KB
testcase_35 AC 14 ms
6,940 KB
testcase_36 AC 73 ms
6,940 KB
testcase_37 AC 34 ms
6,944 KB
testcase_38 AC 109 ms
6,940 KB
testcase_39 AC 69 ms
6,940 KB
testcase_40 AC 134 ms
6,940 KB
testcase_41 AC 77 ms
6,940 KB
testcase_42 AC 134 ms
6,940 KB
testcase_43 AC 157 ms
6,944 KB
testcase_44 AC 2 ms
6,944 KB
testcase_45 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
//using mint = modint998244353;

vector<int> solve(int N, const vector<pair<int,int>>& v, int pos){
  int Q = v.size();

  vector<int> ret;
  
  rep(i,Q){
    int a = v[i].first;
    int b = v[i].second;

    if(pos != a && pos != b){
      ;
    }else{
      if(pos+1<=N && pos+1 != a && pos+1 != b){
        pos++;
      }
      else if(pos-1>=1 && pos-1 != a && pos-1 != b){
        pos--;
      }
      else{
        return vector<int>();
      }
    }

    ret.push_back(pos);
  }

  return ret;
}


int main(){
  int N, Q;
  cin >> N >> Q;
  vector<pair<int,int>> v(Q);
  rep(i,Q) cin >> v[i].first;
  rep(i,Q) cin >> v[i].second;

  if(v[0].first-1 >= 1){
    vector<int> ret = solve(N, v, v[0].first-1);
    if(ret.size() > 0){
      cout << "YES" << endl;
      cout << ret[0] << endl;
      rep(i,ret.size()) cout << ret[i] << endl;
      return 0;
    }
  }
  if(v[0].second-1 >= 1){
    vector<int> ret = solve(N, v, v[0].second-1);
    if(ret.size() > 0){
      cout << "YES" << endl;
      cout << ret[0] << endl;
      rep(i,ret.size()) cout << ret[i] << endl;
      return 0;
    }
  }
  if(v[0].first+1 <= N){
    vector<int> ret = solve(N, v, v[0].first+1);
    if(ret.size() > 0){
      cout << "YES" << endl;
      cout << ret[0] << endl;
      rep(i,ret.size()) cout << ret[i] << endl;
      return 0;
    }
  }
  if(v[0].second+1 <= N){
    vector<int> ret = solve(N, v, v[0].second+1);
    if(ret.size() > 0){
      cout << "YES" << endl;
      cout << ret[0] << endl;
      rep(i,ret.size()) cout << ret[i] << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  
  return 0;
}

0