QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#325442 | #5533. Trick | hotboy2703 | 0 | 0ms | 0kb | C++14 | 1.7kb | 2024-02-11 13:04:09 | 2024-02-11 13:04:10 |
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL << (i))
mt19937_64 rng(1);
mt19937_64 rng2(chrono::steady_clock::now().time_since_epoch().count());
ll random2(ll l,ll r){
return rng2()%(r-l+1)+l;
}
ll random(ll l,ll r){
return rng()%(r-l+1)+l;
}
ll myrandom(ll i){
return rng()%i;
}
ll pre[1000100];
ll f(ll x,ll y,ll n){
if (x * (2*n+1)+y <= 1000000)return pre[x * (2*n+1)+y] % (2*n+1);
rng.seed((x*(2*n+1)+y+69)*45);
return random(0,2*n);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
// freopen("trick.in","r",stdin);
// freopen("trick.out","w",stdout);
for (ll i= 1;i <= 1000000;i ++)pre[i] = random(0,MASK(60)-1);
ll t;
cin>>t;
ll task;
cin>>task;
while(t--){
ll n;
cin>>n;
if (task==3){
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll res = -(f(a,b,n)+f(c,d,n));
res = (res%(2*n+1)+2*n+1)%(2*n+1);
cout<<res<<'\n';
}
else{
vector <ll> a(n);
ll sum = 0;
for (auto &x:a){cin>>x;sum = (sum+x)%(2*n+1);}
ll u,v;
u = random2(0,sz(a)-1);
v = random2(0,sz(a)-1);
while (u == v || f(a[u],a[v],n) != sum){
u = random2(0,sz(a)-1);
v = random2(0,sz(a)-1);
}
cout<<a[u]<<' '<<a[v]<<'\n';
}
}
}
/*
1 2 12 9
4 2 10 3
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
12012 1 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 6 6 0 1 2 3 4 6 6 0 1 2 3 4 6 6 0 1 2 3 4 6 6 0 1 2 3 4 6 6 0 1 2 3 4 6 6 0 1 2 3 4 6 6 0 1 2 3 5 6 6 0 1 2 3 5 6 6 0 1 2 3 5 6 6 0 1 2 3 5 6 6 0 1 2 3 5 6 6 0 1 2 3 5 6 6 0 1 2 3 5 ...
output:
result:
Subtask #2:
score: 0
Skipped
Subtask #3:
score: 0
Time Limit Exceeded
Test #11:
score: 0
Time Limit Exceeded
input:
6525 1 6 10 1 11 3 12 6 6 1 7 10 12 5 6 6 0 10 12 7 9 8 6 12 1 8 4 7 11 6 11 8 9 4 10 6 6 0 7 2 3 4 5 6 0 8 3 10 11 6 6 0 1 2 4 7 6 6 0 1 11 9 5 6 6 7 1 12 8 6 5 7 0 1 13 10 12 5 6 7 0 14 2 3 4 12 6 7 11 1 3 8 12 6 13 7 0 1 2 3 13 5 14 7 11 9 10 8 4 14 7 7 0 8 14 3 4 13 11 7 0 10 2 14 8 5 6 7 0 13 2...
output:
result:
Subtask #4:
score: 0
Skipped