QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#322045 | #4830. Transfer of Duty | Goldenglow1427 | 0 | 50ms | 17796kb | C++14 | 1.8kb | 2024-02-06 08:17:47 | 2024-02-06 08:17:47 |
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 = 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];
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;
}
cin >> str+1;
if(str[1] == 's')
solve1();
else
solve2();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 50ms
memory: 17796kb
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: 50ms
memory: 17796kb
input:
start 1 1
output:
1 1 1
input:
resume 1 1 1 1
output:
0
result:
ok
Test #3:
score: 0
Stage 1: Program answer Runtime Error
input:
start 1 1000000