QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#671093 | #9518. 观虫我 (旧版数据) | 275307894a | 0 | 4636ms | 536080kb | C++14 | 2.7kb | 2024-10-24 10:49:51 | 2024-10-24 10:49:51 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=N*120+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
using LL=__uint128_t;
int n,q,op[N];
ui X[N];
LL f[1<<25];
int rk[32];
LL pre1[128],pre2[128];
void Solve(){
scanf("%d%d",&n,&q);
for(int i=1;i<=q;i++){
char c=Gc();while(c^'!'&&c^'?') c=Gc();
op[i]=(c=='!');
scanf("%d",&X[i]);
}
int lim=50;
ui A=0,B=0,C=0,S=0;
ll ans=1e18;
while(lim--){
ui a=0,b=0,c=0,s=0;ll tot=0;
static int id[32];
iota(id,id+n,0);shuffle(id,id+n,rnd);
for(int i=7;i<n;i++){
s|=1u<<id[i];
int op=R(3);
if(op==1) a|=1u<<id[i];
else if(op==2) b|=1u<<id[i];
else c|=1u<<id[i];
}
for(int i=1;i<=q;i++){
ui x=X[i]&s;
if(op[i]) tot+=1<<__builtin_popcount((~x&b)|(x&c));
else tot+=1<<__builtin_popcount((x&a)|(~x&c));
}
if(tot<ans) A=a,B=b,C=c,S=s,ans=tot;
gdb(ans);
}
int k=0;
for(int i=0;i<n;i++) if(~S>>i&1) rk[i]=k++;
for(int i=0;i<n;i++) if(S>>i&1) rk[i]=k++;
for(int i=0;i<128;i++){
pre1[i]=LL(1)<<i;
for(int j=0;j<128;j++) if((j&i)==j) pre2[i]|=LL(1)<<j;
}
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
auto work=[](ui &x){
ui z=0;
for(int i=0;i<32;i++) if(x>>i&1) z|=1u<<rk[i];
x=z;
};
work(A);work(B);work(C);
A>>=7;B>>=7;C>>=7;
for(int i=1;i<=q;i++){
work(X[i]);
ui x=X[i]>>7;
if(op[i]){
ui w=pre1[X[i]&127];
ui msk=(~x&B)|(x&C);x^=C;
for(ui i=msk;i;--i&=msk) f[x^i]^=w;f[x]^=w;
}else{
ull w=pre2[X[i]&127];
ui msk=(x&A)|(~x&C);x^=x&A;
ui ans=0;
for(ui i=msk;i;--i&=msk) ans^=f[x^i];ans^=f[x];
ans&=w;
printf("%d\n",__builtin_parity(ans^(ans>>64)));
}
if(i%1000==0&&clock()*1.0/CLOCKS_PER_SEC>4.9) break;
}
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 630ms
memory: 16024kb
input:
24 1000000 ! 9475137 ! 4501536 ? 14277831 ? 16695039 ? 5723102 ? 6093887 ? 3014539 ! 475969 ? 12500973 ! 8750136 ? 15617895 ! 4589313 ! 152300 ? 3612579 ? 15248179 ! 764162 ! 4461105 ? 7274495 ? 13299697 ! 8388872 ? 13490383 ! 3875594 ! 9439685 ? 16776189 ! 6443172 ? 13864879 ! 395691 ? 7142271 ? 16...
output:
1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 0 0 0 1 1 0 1 1 1 1 0 0 0 1 1 0 0 1 0 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 0 1 0 0 1 1 1 0 0 0 1 0 0 1 1 0 1 0 0 1 1 0 1 1 0 0 0 0 1 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 0 1 0 0 ...
result:
wrong answer Wrong answer at operation #18: Incorrect answer.
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 790ms
memory: 21860kb
input:
26 1000000 ! 18006034 ? 66957270 ! 2133064 ! 147618 ! 34621442 ? 49715575 ? 62879287 ! 18620682 ? 67073751 ! 62941186 ! 7634532 ? 67100031 ? 12517237 ! 4804997 ? 65991126 ! 138275 ? 65722687 ? 66043391 ! 19147234 ? 45743743 ! 2242648 ! 44378336 ? 48226020 ! 34341926 ! 665045 ? 55433083 ! 5554254 ? 4...
output:
0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 0 0 0 1 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 1 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1 ...
result:
wrong answer Wrong answer at operation #18: Incorrect answer.
Subtask #3:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 1114ms
memory: 46584kb
input:
28 1000000 ! 1081468 ! 128476263 ! 67930241 ? 94304031 ! 103698752 ! 19982 ! 198050624 ? 249519591 ? 71286719 ? 255700799 ! 103309888 ! 819340 ! 12852092 ? 124739445 ? 192734967 ! 101320328 ! 117594711 ? 252032927 ! 134267948 ? 262940285 ! 3155972 ? 267876218 ! 41984160 ? 246413294 ? 246824252 ? 163...
output:
0 0 1 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 0 1 1 1 0 1 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 1 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 0 0 1 0 0 1 1 1 1 1 1 1 0 1 1 ...
result:
wrong answer Wrong answer at operation #24: Incorrect answer.
Subtask #4:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 2034ms
memory: 144888kb
input:
30 1000000 ! 33852274 ? 1017904007 ? 1046413001 ! 151029382 ? 466826079 ? 250568375 ! 6769874 ! 2106474 ? 536832803 ? 209627867 ! 167104971 ? 1048372157 ! 245380745 ! 25174496 ? 819646460 ! 539548800 ! 671358165 ? 402955591 ? 527753201 ! 582494209 ? 862862931 ? 938974695 ? 263672827 ? 366968669 ? 87...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 1 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 1 0 0 1 1 1 1 0 0 1 0 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 1 0 1 1 1 1 0 0 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 0 1 0 1 ...
result:
wrong answer Wrong answer at operation #51: Incorrect answer.
Subtask #5:
score: 0
Wrong Answer
Test #41:
score: 0
Wrong Answer
time: 4636ms
memory: 536080kb
input:
32 1000000 ! 2474971548 ! 348268033 ? 1055293046 ? 3382525679 ? 1805515707 ? 3210332902 ? 2805668987 ? 4025974780 ! 2217771280 ! 176949664 ! 4213841344 ! 1477473321 ? 3150869759 ? 2127418041 ! 1610631720 ! 3624477314 ! 2288149532 ! 70909964 ! 40117153 ! 1343751456 ? 3758095615 ! 513059275 ! 31956816...
output:
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 ...
result:
wrong answer Wrong answer at operation #21: Incorrect answer.