QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#869517 | #9685. nim 游戏 | nullptr_qwq | 0 | 0ms | 0kb | C++14 | 2.6kb | 2025-01-25 10:42:00 | 2025-01-25 10:42:01 |
Judging History
你现在查看的是最新测评结果
- [2025-01-27 09:19:35]
- hack成功,自动添加数据
- (/hack/1490)
- [2025-01-27 08:19:11]
- hack成功,自动添加数据
- (/hack/1488)
- [2025-01-26 18:55:44]
- hack成功,自动添加数据
- (/hack/1475)
- [2025-01-25 10:42:00]
- 提交
answer
// Problem: T486367 【模拟#4】故障机器人
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/T486367
// Memory Limit: 512 MB
// Time Limit: 1000 ms
// Author: nullptr_qwq
//
// Powered by CP Editor (https://cpeditor.org)
// 私は猫です
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define dF(i,a,b) for(int i=(a);i>=(b);i--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) (x&(-x))
#define HH printf("\n")
#define eb emplace_back
#define poly vector<int>
using namespace std;
ll read(){
ll x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
return x*f;
}
const int mod=998244353,maxn=1000005;
inline void chkmax(int &x,const int y){ x=max(x,y); }
inline void chkmin(int &x,const int y){ x=min(x,y); }
inline void chkmax(ll &x,const ll y){ x=max(x,y); }
inline void chkmin(ll &x,const ll y){ x=min(x,y); }
ll a[maxn];
int n,vis[maxn];
void solve(){
n=read();
F(i,1,n)a[i]=read(),vis[i]=0;
ll Xorsum=0;
F(i,1,n)Xorsum^=a[i];
if(!Xorsum)return puts("0"),puts("0"),void();
vector<ll>vec;
function<ll(int,ll)>upper=[&](int x,ll y){
return (1ll<<x)-(((1ll<<x)-1)&y);
};
dF(i,60,0){
ll mn=infll,sec=infll;
int p=-1,q=-1;
F(j,1,n)if(!vis[j]&&!((a[j]>>i)&1)){
const ll val=upper(i,a[j]);// let a[j]_i=1,a[j]_{>i}=0
if(val<mn)q=p,sec=mn,p=j,mn=val;
else if(val<sec)q=j,sec=val;
}
if(~p)vis[p]=1,vec.push_back(a[p]);
if(~q)vis[q]=1,vec.push_back(a[q]);
}
const int siz=vec.size();
function<ll(int)>calc=[&](int x){
ll res=0,cur=Xorsum;
vector<ll>f=vec;
function<int(int)>oper=[&](int t){
int p=-1;
ll mn=infll;
F(i,0,siz-1)if(!((f[i]>>t)&1)){
const ll val=upper(t,f[i]);
if(val<mn)p=i,mn=val;
}
if(p<0)return 0;
res+=mn,cur^=(f[p]^(1ll<<t));
f[p]^=(((1ll<<t)-1)&f[p])^(1ll<<t);
return 1;
};
if(!((cur>>x)&1)){
if(!oper(x))return infll;
if(!oper(x))return infll;
}
else if(!oper(x))return infll;
dF(i,x-1,0)if(((cur>>i)&1)&&!oper(i))return infll;
return res;
};
ll ans=infll;
dF(i,61,0){
chkmin(ans,calc(i));
if((Xorsum>>i)&1)break;
}
cout<<ans<<'\n'; puts("0");
}
signed main(){
read(); int sjy=read();
cmh(sjy) solve();
}
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:
1 10000 2 1 324097321 555675086 2 1 304655177 991244276 2 1 9980291 383616352 2 1 1071036550 795625380 2 1 682098056 68370721 2 1 969101726 685975156 2 1 973896269 354857775 2 1 196188000 606494155 2 1 754416123 467588829 2 1 495704303 558090120 2 1 618002000 491488050 2 1 741575237 9937018 2 1 1002...
output:
result:
Subtask #2:
score: 0
Time Limit Exceeded
Test #2:
score: 0
Time Limit Exceeded
input:
2 5 5 2000 0 13 3 4 10 5 2000 0 3 9 1 11 5 2000 0 13 7 3 5 5 2000 0 1 13 9 2 5 2000 0 8 14 7 13
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Time Limit Exceeded
Test #8:
score: 0
Time Limit Exceeded
input:
4 257 100000 100 32768 65536 262144 32768 8388608 1048576 4 67108864 16384 32768 262144 8192 512 134217728 65536 4194304 262144 67108864 1024 262144 64 32 65536 2097152 268435456 1 2048 4194304 16777216 8 16384 2 2048 16777216 268435456 262144 1048576 8388608 16 268435456 2 128 4194304 262144 32768 ...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #18:
score: 0
Time Limit Exceeded
input:
5 10000 10 1 0 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 10 1 0 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 10 1 0 1073741823 1073741823 1073741823 1073741823 1073741823 1073741823 1073741...
output:
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #22:
score: 0
Time Limit Exceeded
input:
6 23 1000 10 0 357293452 452461848 986047039 546588280 762710079 767831017 39741545 416114273 515599366 1018969624 603342125 928112286 1053016142 240953466 533088067 1028134429 504727014 371307863 834428873 968387878 478550336 1047217797 1046651542 777749850 866989319 92995163 251915198 363285573 10...
output:
result:
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #7:
0%
Subtask #9:
score: 0
Skipped
Dependency #8:
0%