QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#86711 | #4830. Transfer of Duty | Dr_Gilbert | 0 | 1037ms | 106660kb | C++14 | 1.5kb | 2023-03-10 16:45:51 | 2023-03-10 16:45:53 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef unsigned long long ull;
mt19937_64 getsed(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e6+10;
namespace anya{
ull v1[N],v2[N],v3[N],n=1e6;
map<tuple<ull,ull,ull>,int> mp;
void solve(){
ull sd1=getsed(),sd2=getsed(),sd3=getsed();
mt19937_64 r1(sd1),r2(sd2),r3(sd3);
for (int i=1;i<=n;i++){
v1[i]=r1(),v2[i]=r2(),v3[i]=r3();
mp[{v1[i],v2[i],v3[i]}]=i-1;
}ull m,res1=0,res2=0,res3=0;cin>>m;
mp[{0,0,0}]=0;
for (int i=1;i<=m;i++){
int x;cin>>x;x++;
res1^=v1[x];res2^=v2[x];res3^=v3[x];
if (!mp.count({res1,res2,res3})) cout<<-1<<endl;
else cout<<mp[{res1,res2,res3}]<<endl;
}cout<<sd1<<' '<<sd2<<' '<<sd3<<' '<<res1<<' '<<res2<<' '<<res3<<endl;
return;
}
}
namespace andrei{
ull v1[N],v2[N],v3[N],n=1e6;
map<tuple<ull,ull,ull>,int> mp;
void solve(){
ull sd1,sd2,sd3,res1,res2,res3;
cin>>sd1>>sd2>>sd3>>res1>>res2>>res3;
mt19937_64 r1(sd1),r2(sd2),r3(sd3);
for (int i=1;i<=n;i++){
v1[i]=r1(),v2[i]=r2(),v3[i]=r3();
mp[{v1[i],v2[i],v3[i]}]=i-1;
}int m;cin>>m;mp[{0,0,0}]=0;
for (int i=1;i<=m;i++){
int x;cin>>x;x++;
res1^=v1[x];res2^=v2[x];res3^=v3[x];
if (!mp.count({res1,res2,res3})) cout<<-1<<endl;
else cout<<mp[{res1,res2,res3}]<<endl;
}return;
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);cout.tie(nullptr);
string s;cin>>s;
if (s=="start") anya::solve();
else andrei::solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1024ms
memory: 106456kb
input:
start 5 10 14 10 12 10
output:
10 -1 14 -1 -1 15547623152959213041 15493558779699072601 16464848528073061597 15772121232512183882 15547347408572974702 6160596803855958048
input:
resume 15547623152959213041 15493558779699072601 16464848528073061597 15772121232512183882 15547347408572974702 6160596803855958048 6 14 277 12 10 277 12
output:
-1 -1 -1 277 0 12
result:
ok
Test #2:
score: 100
Accepted
time: 1037ms
memory: 106660kb
input:
start 1 1
output:
1 5318147602122819993 15548865467630032333 18094060044969050494 6652963574420324003 12147273625099692653 1163036892574283276
input:
resume 5318147602122819993 15548865467630032333 18094060044969050494 6652963574420324003 12147273625099692653 1163036892574283276 1 1
output:
0
result:
ok
Test #3:
score: 0
Wrong Answer on the first run
input:
start 1 1000000
output:
0 1413815123693446249 2076109081314184377 9401859497859175657 0 0 0
input:
output:
result:
wrong answer wrong answer on the first run, query 1: read 0 but expected 1000000