QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#437334 | #4830. Transfer of Duty | biank23 | 0 | 814ms | 73568kb | C++14 | 1.7kb | 2024-06-09 08:05:54 | 2024-06-09 08:05:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define all(x) begin(x),end(x)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
#define dbg(x) cerr<<#x<<": "<<x<<endl
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
//const int MAXN = 2e5+5;
//const ll INF = 1e18;
const int MOD = 1e9+7;
template<class x> ostream & operator<<(ostream & out, vector<x> v){
out<<"[ ";
for(auto y : v) out<<y<<" ";
out<<"]";
return out;
}
template<class a, class b> ostream & operator<<(ostream & out, pair<a, b> p){
return out<<"("<<p.fst<<", "<<p.snd<<")";
}
int main(){
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
string run;
cin>>run;
vll h(1e6+1);
map<ll,int> s;
s[0]=0;
forsn(i,1,1e6+1){
h[i]=rand()%ll(1e18);
s[h[i]]=i;
}
ll x=0;
if(run=="resume"){
string m;
cin.ignore();
getline(cin,m);
forn(i,sz(m)) x=x*95+(m[i]-32);
}
int n;
cin>>n;
forn(i,n){
int p;
cin>>p;
x^=h[p];
if(s.count(x)) cout<<s[x]<<'\n';
else cout<<"-1\n";
}
if(run=="start"){
string m="";
do m+=char(32+x%95);
while(x/=95);
reverse(all(m));
cout<<m<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 778ms
memory: 73392kb
input:
start 5 10 14 10 12 10
output:
10 -1 14 -1 -1 1z ;A
input:
resume 1z ;A 6 14 277 12 10 277 12
output:
-1 -1 -1 277 0 12
result:
ok
Test #2:
score: 100
Accepted
time: 744ms
memory: 73568kb
input:
start 1 1
output:
1 6.I8n
input:
resume 6.I8n 1 1
output:
0
result:
ok
Test #3:
score: 100
Accepted
time: 814ms
memory: 73400kb
input:
start 1 1000000
output:
1000000 %9j:A
input:
resume %9j:A 2 1 1000000
output:
-1 1
result:
ok
Test #4:
score: 100
Accepted
time: 773ms
memory: 73540kb
input:
start 2 1 1
output:
1 0
input:
resume 2 1000000 1000000
output:
1000000 0
result:
ok
Test #5:
score: 100
Accepted
time: 720ms
memory: 73500kb
input:
start 3 1 2 3
output:
1 -1 -1 ,e>p3
input:
resume ,e>p3 2 4 5
output:
-1 -1
result:
ok
Test #6:
score: 100
Accepted
time: 704ms
memory: 73372kb
input:
start 5 483440 800458 959493 679027 187008
output:
483440 -1 -1 -1 -1 *ZP'%
input:
resume *ZP'% 8 312653 808184 244728 372836 64144 525068 795548 379152
output:
-1 -1 -1 -1 -1 -1 -1 -1
result:
ok
Test #7:
score: 0
Wrong Answer on the first run
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 295258 -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 5g_42
input:
output:
result:
wrong answer wrong answer on the first run, query 30: read 295258 but expected -1