Submission #00078
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | #include <bits/stdc++.h> #define lol long long #define gcd(x, y) __gcd(x, y) #define mt make_tuple #define mp make_pair #define fi first #define se second #define fixed(x) fixed << setprecision(x) #define all(x) x.begin(),x.end() using namespace std; using pii = pair< int , int >; template < class A, class B> inline bool chmax(A& a, const B& b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A& a, const B& b) { return b < a && (a = b, true ); } template < class A> inline A abs (A& a) { return (a < 0 ? -a : a); } bool inLine( int x, int y, int mx, int my) { return (x >= 0 && y >= 0 && x < mx && y < my); } template < class T> using max_heap=priority_queue<T>; template < class T> using min_heap=priority_queue<T,vector<T>,greater<T>>; template < class T> using uset=unordered_set<T>; template < class A, class B> using umap=unordered_map<A,B>; const lol inf = (1LL << 62); const int MOD = (1e9) + 7; const int mod = 998244353; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1, -2, -2, -2, -2, -2, -1, -1, 1, 1, 0, 0, 2, 2, 2, 2, 2}; const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1, -2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2}; signed main() { cin.tie(0); ios::sync_with_stdio( false ); int n,m,Q; cin >>n>>m>>Q; vector< int > a(m),q(Q); for ( int i=0;i<m;i++) cin >>a[i]; for ( int i=0;i<Q;i++) cin >>q[i]; set< int > s; for ( int i=0;i<n;i++){ s.insert(i); } auto bo=s.begin(); for ( int i=0;i<m;i++){ int p=s.size(); if (a[i]%2){ // 版図系 a[i]%=p; int tmp=0; if (bo==s.begin()){ tmp=1; } while (a[i]>0){ a[i]--; if (tmp){ bo=s.end(); tmp=0; } bo--; if (bo==s.begin()){ tmp=1; } } } else { // 時計 a[i]%=p; while (a[i]>0){ a[i]--; bo++; if (bo==s.end()){ bo=s.begin(); } } } auto tmp=bo; bo++; if (bo==s.end()){ bo=s.begin(); } s.erase(tmp); } for ( int i=0;i<Q;i++){ if (s.find(q[i])!=s.end()){ cout << "1\n" ; } else { cout << "0\n" ; } } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0007 - バトンリレーゲーム |
ユーザー名 | 保守性不在 |
投稿日時 | 2021-07-13 17:35:51 |
言語 | C++17 |
状態 | Accepted |
得点 | 12 |
ソースコード長 | 2311 Byte |
最大実行時間 | 69 ms |
最大メモリ使用量 | 10072 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 12 / 12 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
00sample.in | AC | 24 ms | 476 KB |
1
|
01.in | AC | 21 ms | 688 KB |
1
|
02.in | AC | 24 ms | 1024 KB |
1
|
03.in | AC | 23 ms | 1236 KB |
1
|
04.in | AC | 24 ms | 1476 KB |
1
|
05.in | AC | 28 ms | 1708 KB |
1
|
06.in | AC | 34 ms | 1972 KB |
1
|
07.in | AC | 38 ms | 2292 KB |
1
|
08.in | AC | 28 ms | 2424 KB |
1
|
09.in | AC | 35 ms | 2768 KB |
1
|
10.in | AC | 39 ms | 2996 KB |
1
|
11.in | AC | 31 ms | 3236 KB |
1
|
12.in | AC | 35 ms | 3472 KB |
1
|
13.in | AC | 41 ms | 3736 KB |
1
|
14.in | AC | 37 ms | 4048 KB |
1
|
15.in | AC | 32 ms | 4072 KB |
1
|
16.in | AC | 43 ms | 4568 KB |
1
|
17.in | AC | 45 ms | 4732 KB |
1
|
18.in | AC | 38 ms | 4796 KB |
1
|
19.in | AC | 57 ms | 4988 KB |
1
|
20.in | AC | 44 ms | 5120 KB |
1
|
21.in | AC | 40 ms | 5468 KB |
1
|
22.in | AC | 51 ms | 5848 KB |
1
|
23.in | AC | 54 ms | 6144 KB |
1
|
24.in | AC | 54 ms | 6372 KB |
1
|
25.in | AC | 49 ms | 6600 KB |
1
|
26.in | AC | 50 ms | 6864 KB |
1
|
27.in | AC | 51 ms | 7196 KB |
1
|
28.in | AC | 43 ms | 7360 KB |
1
|
29.in | AC | 47 ms | 7628 KB |
1
|
30.in | AC | 58 ms | 7756 KB |
1
|
31.in | AC | 60 ms | 8108 KB |
1
|
32.in | AC | 59 ms | 8344 KB |
1
|
33.in | AC | 62 ms | 8484 KB |
1
|
34.in | AC | 53 ms | 8668 KB |
1
|
35.in | AC | 68 ms | 8896 KB |
1
|
36.in | AC | 58 ms | 9404 KB |
1
|
37.in | AC | 61 ms | 9508 KB |
1
|
38.in | AC | 69 ms | 9676 KB |
1
|
39.in | AC | 64 ms | 9880 KB |
1
|
40.in | AC | 60 ms | 10072 KB |
1
|