QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#61571 | #4830. Transfer of Duty | Booksnow | 0 | 513ms | 61444kb | C++14 | 1.4kb | 2022-11-14 09:37:47 | 2023-02-13 21:07:25 |
Judging History
answer
#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define ldb long double
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
const int N = 1e6 + 10, lim = 1e6, mod = 998244353;
inline int read()
{
int s = 0, w = 1;
char ch = getchar();
while(ch < '0' || ch > '9') { if(ch == '-') w *= -1; ch = getchar(); }
while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
string op;
ull id[N];
int n, s, c, k[N];
inline ull rnd() { return (ull)rand() * rand(); }
unordered_map<ull, int> mp;
inline void Sol(int fl)
{
for(re int i = 1; i <= lim; i++) k[i] = 1;
for(re int i = 1; i <= lim; i++) id[i] = rnd(), mp[id[i]] = i;
if(fl){
c = read();
for(re int i = 1, x; i <= c; i++) x = read(), s += k[x] * id[x], k[x] *= -1;
}
n = read();
while(n--){
int x = read();
s += k[x] * id[x], c += k[x], k[x] *= -1;
if(!s) puts("0");
else if(mp.find(s) != mp.end()) printf("%lld\n", mp[s]);
else puts("-1");
}
if(!fl){
printf("%lld ", c);
for(re int i = 1; i <= lim; i++) if(k[i] == -1) printf("%lld ", i);
}
}
signed main()
{
srand((unsigned)(time(0)));
cin >> op;
if(op == "start") Sol(0);
else Sol(1);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 513ms
memory: 61356kb
input:
start 5 10 14 10 12 10
output:
10 -1 14 -1 -1 3 10 12 14
input:
resume 3 10 12 14 6 14 277 12 10 277 12
output:
-1 -1 -1 277 0 12
result:
ok
Test #2:
score: 100
Accepted
time: 492ms
memory: 61336kb
input:
start 1 1
output:
1 1 1
input:
resume 1 1 1 1
output:
0
result:
ok
Test #3:
score: 100
Accepted
time: 474ms
memory: 61424kb
input:
start 1 1000000
output:
1000000 1 1000000
input:
resume 1 1000000 2 1 1000000
output:
-1 1
result:
ok
Test #4:
score: 100
Accepted
time: 503ms
memory: 61444kb
input:
start 2 1 1
output:
1 0 0
input:
resume 0 2 1000000 1000000
output:
1000000 0
result:
ok
Test #5:
score: 100
Accepted
time: 470ms
memory: 61220kb
input:
start 3 1 2 3
output:
1 -1 -1 3 1 2 3
input:
resume 3 1 2 3 2 4 5
output:
-1 -1
result:
ok
Test #6:
score: 100
Accepted
time: 469ms
memory: 61356kb
input:
start 5 483440 800458 959493 679027 187008
output:
483440 -1 -1 -1 -1 5 187008 483440 679027 800458 959493
input:
resume 5 187008 483440 679027 800458 959493 8 312653 808184 244728 372836 64144 525068 795548 379152
output:
-1 -1 -1 -1 -1 -1 -1 -1
result:
ok
Test #7:
score: 100
Accepted
time: 487ms
memory: 61428kb
input:
start 68 901287 581649 963302 839936 728540 414441 916931 567596 695928 364562 839701 726560 34000 85414 129234 413159 976576 799600 479209 808330 182632 685443 41419 207533 762418 206283 144088 679114 945142 919478 220106 992468 483248 197576 129732 123083 987094 712824 650777 907335 206313 958433 ...
output:
901287 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 68 4051 34000 41419 70325 85414 103803 107840 119476 123083 124793 129234 129374 129732 144...
input:
resume 68 4051 34000 41419 70325 85414 103803 107840 119476 123083 124793 129234 129374 129732 144088 182632 197576 206283 206313 207533 220106 229431 299922 364562 375065 404445 413159 414441 440318 444334 460595 471301 479209 483248 503482 533299 567596 581649 609455 612915 650777 679114 685443 6...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
result:
ok
Test #8:
score: 0
Wrong Answer on the first run
input:
start 520 569396 440938 116732 473751 47601 877390 277114 259139 437475 193896 992342 402838 838349 33699 536576 163847 117713 927965 598864 939506 517156 87428 943725 624835 515205 108250 468405 990560 512040 343417 101050 944099 177534 73824 476709 772630 489775 929453 216227 822538 552185 208923 ...
output:
569396 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
input:
output:
result:
wrong answer the length of the notes exceeds 1,000