QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#509728 | #1977. The Last Supper | PetroTarnavskyi# | AC ✓ | 8ms | 5284kb | C++20 | 1.6kb | 2024-08-08 17:58:27 | 2024-08-08 17:58:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, q;
cin >> n >> m >> q;
VI sick(m);
FOR (i, 0, m)
{
cin >> sick[i];
sick[i]--;
}
VI pref(n + 1);
FOR (i, 0, m)
pref[sick[i] + 1] = 1;
FOR (i, 0, n)
pref[i + 1] += pref[i];
vector<pair<int, char>> v(q);
FOR (i, 0, q)
{
cin >> v[i].F >> v[i].S;
v[i].F--;
}
VI cntL(n), cntR(n);
RFOR (i, q, 0)
{
if (v[i].S == 'R')
cntL[v[i].F] = 1 + cntL[(v[i].F + n - 1) % n];
else
cntR[v[i].F] = 1 + cntR[(v[i].F + 1) % n];
}
VI ans;
FOR (i, 0, n)
{
//cerr << i << ' ' << cntL[i] << ' ' << cntR[i] << '\n';
if (1 + cntL[i] + cntR[i] >= n)
{
ans.PB(i + 1);
continue;
}
int R = (i + cntR[i]) % n;
int L = (i - cntL[i] + n) % n;
int l = (R + 1) % n, r = (L + n - 1) % n;
//cerr << i << ' ' << cntL[i] << ' ' << cntR[i] << ' ' << L << ' ' << R << ' ' << l << ' ' << r << '\n';
if (l <= r)
{
if (pref[r + 1] - pref[l] == 0)
ans.PB(i + 1);
}
else
{
if (pref[n] - pref[l] + pref[r + 1] == 0)
ans.PB(i + 1);
}
}
FOR (i, 0, SZ(ans))
{
if (i)
cout << ' ';
cout << ans[i];
}
cout << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
3 1 3 2 1 L 2 L 3 L
output:
1 2
result:
ok single line: '1 2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
3 2 2 2 3 1 R 3 R
output:
1 3
result:
ok single line: '1 3'
Test #3:
score: 0
Accepted
time: 6ms
memory: 3888kb
input:
400 260 100000 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 226 227 228 229 230 231 232 233 234 235...
output:
346 347 348 349 350 351 352 353 354 355 356 357 358
result:
ok single line: '346 347 348 349 350 351 352 353 354 355 356 357 358'
Test #4:
score: 0
Accepted
time: 5ms
memory: 3980kb
input:
1000 8 100000 101 113 120 152 156 164 177 191 429 L 897 L 63 L 470 L 95 R 610 L 417 R 1 L 958 R 671 R 931 R 171 R 512 R 935 L 75 L 298 R 538 R 830 R 580 L 986 L 377 L 232 R 861 L 32 L 113 R 852 R 202 L 946 R 784 L 213 L 56 L 108 L 667 L 234 L 653 R 828 R 175 L 886 L 5 L 350 L 304 R 600 L 916 R 912 R...
output:
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
result:
ok single line: '135 136 137 138 139 140 141 14...151 152 153 154 155 156 157 158'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3964kb
input:
8191 2043 49152 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 ...
output:
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 102 ...
result:
ok single line: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...3 2044 2045 2046 2047 2048 2049'
Test #6:
score: 0
Accepted
time: 3ms
memory: 3788kb
input:
8191 13 49152 513 514 515 516 517 518 519 520 521 522 523 524 525 1 R 8191 R 1 L 8190 R 2 L 8189 R 3 L 4 L 8188 R 8187 R 5 L 6 L 7 L 8186 R 8185 R 8 L 9 L 10 L 8184 R 11 L 8183 R 12 L 8182 R 8181 R 8180 R 13 L 8179 R 14 L 8178 R 8177 R 15 L 16 L 8176 R 17 L 8175 R 8174 R 18 L 19 L 20 L 21 L 8173 R 2...
output:
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 102 ...
result:
ok single line: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...3 2044 2045 2046 2047 2048 2049'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
10000 1001 17000 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 605...
output:
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 102 ...
result:
ok single line: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...4 5995 5996 5997 5998 5999 6000'
Test #8:
score: 0
Accepted
time: 6ms
memory: 4080kb
input:
10000 1 100000 2838 58 L 3624 L 4162 R 8328 L 7014 R 7581 R 405 R 7474 L 4069 R 1221 R 5279 R 810 L 7678 L 8439 L 148 R 8853 L 1974 L 6469 L 3499 L 968 R 208 R 966 L 39 R 8361 R 9043 L 9375 L 8925 R 827 R 3539 L 2931 R 5219 R 5476 R 2533 L 8170 L 1070 R 8105 L 254 R 7943 R 9139 R 9967 L 2435 L 1615 ...
output:
2834 2835 2836 2837 2838 2839 2840 2841 2842
result:
ok single line: '2834 2835 2836 2837 2838 2839 2840 2841 2842'
Test #9:
score: 0
Accepted
time: 8ms
memory: 4756kb
input:
30000 9999 100000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 ...
output:
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 102 ...
result:
ok single line: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...5 29996 29997 29998 29999 30000'
Test #10:
score: 0
Accepted
time: 8ms
memory: 4576kb
input:
30000 19999 100000 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...
output:
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 102 ...
result:
ok single line: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...5 29996 29997 29998 29999 30000'
Test #11:
score: 0
Accepted
time: 3ms
memory: 5284kb
input:
100000 1 100000 96959 39845 L 36811 R 5808 R 64320 L 25148 L 61889 R 33418 L 57458 R 80061 R 40471 R 63517 R 23740 R 52216 R 77934 R 62300 L 94688 R 61823 L 16679 R 56119 L 75582 L 17218 L 79683 R 59648 L 67512 R 25651 R 78755 R 88166 L 75630 R 18755 L 39176 R 40923 L 53185 R 25699 L 41778 R 19025 R...
output:
96958 96959
result:
ok single line: '96958 96959'