結果
問題 | No.1508 Avoid being hit |
ユーザー | chocorusk |
提出日時 | 2021-05-14 23:57:28 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,579 bytes |
コンパイル時間 | 3,815 ms |
コンパイル使用メモリ | 191,936 KB |
実行使用メモリ | 45,940 KB |
最終ジャッジ日時 | 2024-04-10 05:01:09 |
合計ジャッジ時間 | 9,711 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 243 ms
45,940 KB |
testcase_01 | AC | 4 ms
8,324 KB |
testcase_02 | AC | 4 ms
8,304 KB |
testcase_03 | AC | 3 ms
8,124 KB |
testcase_04 | AC | 4 ms
8,260 KB |
testcase_05 | AC | 4 ms
8,120 KB |
testcase_06 | AC | 4 ms
8,164 KB |
testcase_07 | AC | 4 ms
8,440 KB |
testcase_08 | AC | 4 ms
8,236 KB |
testcase_09 | AC | 3 ms
8,260 KB |
testcase_10 | AC | 4 ms
8,288 KB |
testcase_11 | AC | 4 ms
8,332 KB |
testcase_12 | AC | 4 ms
8,244 KB |
testcase_13 | AC | 3 ms
8,172 KB |
testcase_14 | AC | 3 ms
8,240 KB |
testcase_15 | AC | 3 ms
8,236 KB |
testcase_16 | AC | 67 ms
20,224 KB |
testcase_17 | AC | 39 ms
14,736 KB |
testcase_18 | AC | 40 ms
16,484 KB |
testcase_19 | AC | 54 ms
17,240 KB |
testcase_20 | AC | 98 ms
28,328 KB |
testcase_21 | AC | 65 ms
20,776 KB |
testcase_22 | AC | 79 ms
23,864 KB |
testcase_23 | AC | 88 ms
26,256 KB |
testcase_24 | AC | 259 ms
41,964 KB |
testcase_25 | AC | 237 ms
39,064 KB |
testcase_26 | AC | 20 ms
10,504 KB |
testcase_27 | AC | 121 ms
23,816 KB |
testcase_28 | AC | 122 ms
23,908 KB |
testcase_29 | AC | 239 ms
39,516 KB |
testcase_30 | AC | 131 ms
25,048 KB |
testcase_31 | AC | 208 ms
35,876 KB |
testcase_32 | AC | 227 ms
37,904 KB |
testcase_33 | AC | 65 ms
16,376 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 | 5 ms
8,320 KB |
testcase_45 | AC | 4 ms
8,240 KB |
ソースコード
#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=-5; i<=5; 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<=5 || d2<=5)){ pr[i+1][y]=x; } } } } if(pr[q].empty()){ cout<<"NO"<<endl; 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; }