QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#322047 | #4830. Transfer of Duty | Goldenglow1427 | 0 | 1332ms | 145048kb | C++14 | 1.9kb | 2024-02-06 08:21:33 | 2024-02-06 08:21:34 |
Judging History
answer
/*
ID: Victor Chen [mail_vi1]
PROG: Transfer of Duty
LANG: C++
*/
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
const int Maxn = 1e6;
const int Maxm = 1e5;
const ll mod1 = 19260817;
const ll mod2 = 1e9+7;
map<ll, int> mp1, mp2;
int n;
ll a1[Maxn+10], a2[Maxn+10];
ll res1, res2;
char str[Maxn+10];
void solve1()
{
cin >> n;
mp1[1] = mp2[1] = 1;
for(int i=1; i<=n; i++)
{
int x;
cin >> x;
res1 ^= a1[x];
res2 ^= a2[x];
if(res1 == 0 && res2 == 0)
cout << 0 << endl;
else
{
int k1 = mp1[res1], k2 = mp2[res2];
if(k1 == 0 || k2 == 0 || k1 != k2)
cout << -1 << endl;
else
cout << k1 << endl;
}
}
cout << res1 << " " << res2 << endl;
}
void solve2()
{
cin >> res1 >> res2;
cin >> n;
for(int i=1; i<=n; i++)
{
int x;
cin >> x;
res1 ^= a1[x];
res2 ^= a2[x];
if(res1 == 0 && res2 == 0)
cout << 0 << endl;
else
{
int k1 = mp1[res1], k2 = mp2[res2];
// cout << k1 << " " << k2 << endl;
if(k1 == 0 || k2 == 0 || k1 != k2)
cout << -1 << endl;
else
cout << k1 << endl;
}
}
}
int main()
{
ios::sync_with_stdio(false);
a1[1] = a2[1] = 1;
for(int i=2; i<=Maxn; i++)
{
a1[i] = a1[i-1] * 2;
a1[i] %= mod1;
a2[i] = a1[i-1] * 2;
a1[i] %= mod2;
mp1[a1[i]] = i;
mp2[a2[i]] = i;
}
mp1[1] = mp2[1] = 1;
cin >> str+1;
if(str[1] == 's')
solve1();
else
solve2();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1237ms
memory: 144632kb
input:
start 5 10 14 10 12 10
output:
10 -1 14 -1 -1 10752 10752
input:
resume 10752 10752 6 14 277 12 10 277 12
output:
-1 -1 -1 277 0 12
result:
ok
Test #2:
score: 100
Accepted
time: 1240ms
memory: 144844kb
input:
start 1 1
output:
1 1 1
input:
resume 1 1 1 1
output:
0
result:
ok
Test #3:
score: 100
Accepted
time: 1332ms
memory: 144360kb
input:
start 1 1000000
output:
1000000 18481639 37742456
input:
resume 18481639 37742456 2 1 1000000
output:
-1 1
result:
ok
Test #4:
score: 100
Accepted
time: 1266ms
memory: 145048kb
input:
start 2 1 1
output:
1 0 0 0
input:
resume 0 0 2 1000000 1000000
output:
1000000 0
result:
ok
Test #5:
score: 100
Accepted
time: 1310ms
memory: 144360kb
input:
start 3 1 2 3
output:
1 -1 -1 7 7
input:
resume 7 7 2 4 5
output:
-1 -1
result:
ok
Test #6:
score: 0
Wrong Answer on the first run
input:
start 5 483440 800458 959493 679027 187008
output:
483440 162411 -1 -1 -1 25505248 58830396
input:
output:
result:
wrong answer wrong answer on the first run, query 2: read 162411 but expected -1