QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#867387 | #9685. nim 游戏 | lgvc# | 2 | 143ms | 8648kb | C++23 | 1.9kb | 2025-01-23 15:13:41 | 2025-01-23 15:13:48 |
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-23 15:13:41]
- 提交
answer
#include <bits/stdc++.h>
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
*pp++=ch;
}
inline void pcc(){
fwrite(buf2,1,pp-buf2,stdout);
pp=buf2;
}
inline int read(void){
int w=1;
register int x(0);register char c(getchar());
while(c<'0'||c>'9'){if(c=='-') w=-1;c=getchar();}
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return w*x;
}
void write(int x){
static int sta[20];
int top=0;
do{
sta[top++]=x%10,x/=10;
}while(x);
while(top) pc(sta[--top]+48);
}
void we(int x){
write(x);
pc('\n');
}
int C,T,N,M,a[1000009],b[1000009];
#define LL long long
LL sv() {
LL aq=0;
for(int i=30;i>=0;i--) {
bool ff=0;
int ss=0;
for(int j=1;j<=N;j++) {
if((a[j]>>i)&1) ff^=1;
ss^=a[j];
}
if(ff) {
int ans=(1<<31)-1;
for(int j=1;j<=N;j++) {
if((a[j]>>i)%2==0) {
int x=(a[j]&((1<<i)-1));
ans=std::min(ans,(1<<i)-x);
}
}
for(int j=1;j<=N;j++) {
if((a[j]>>i)%2==0) {
int x=(a[j]&((1<<i)-1));
if(ans==(1<<i)-x) {
a[j]+=(1<<i)-x;
aq+=(1<<i)-x;
break;
}
}
}
}
}
return aq;
}
#define INF_LL 0x3f3f3f3f3f3f3f3f
signed main(void) {
C=read();T=read();
while(T--) {
N=read();M=read();
int ss=0;
for(int i=1;i<=N;i++) {
a[i]=read();
b[i]=a[i];
ss^=a[i];
}
if(ss==0) {
printf("1\n1\n0\n\n\n");
continue;
}
long long ans=INF_LL;
for(int i=1;i<=N;i++) {
for(int j=30;j>=0;j--) {
if(ss>=(1<<j+1)) continue;
if(((a[i]>>j)&1)==0) {
int vv=(a[i]&((1<<j)-1));
a[i]+=(1<<j)-vv;
ans=std::min(ans,(1<<j)-vv+sv());
for(int k=1;k<=N;k++) a[k]=b[k];
}
}
}
printf("%lld\n0\n",ans);
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 2
Acceptable Answer
Test #1:
score: 2
Acceptable Answer
time: 5ms
memory: 8244kb
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:
231577765 0 686589099 0 373636061 0 275411170 0 613727335 0 283126570 0 619038494 0 410306155 0 286827294 0 62385817 0 126513950 0 731638219 0 130065995 0 295114692 0 301034148 0 338094653 0 290055064 0 616102407 0 683296497 0 58868131 0 408003947 0 892535230 0 212031631 0 386722635 0 655774471 0 55...
result:
points 0.5 right answer but not right solutions at 10000th solution
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 7888kb
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:
1 1 0 1 1 0 2 0 3 0 2 0
result:
wrong answer used stones does not equal to outputed k
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: 6
Acceptable Answer
time: 6ms
memory: 8648kb
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:
1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1073741823 0 1...
result:
points 0.5 right answer but not right solutions at 10000th solution
Test #19:
score: 0
Time Limit Exceeded
input:
5 2323 100000 1 0 3170633 888529329 347839787 101667249 273239696 1028446182 411994109 710973319 298677951 299452068 519308796 361451040 488605068 74238166 997794448 478367019 532094220 747266199 217905213 682359917 774814810 234838947 456387659 38459020 434013070 633290806 173828476 94076883 568288...
output:
result:
Subtask #6:
score: 0
Wrong Answer
Test #22:
score: 8
Acceptable Answer
time: 94ms
memory: 7900kb
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:
264227 0 5 0 7 0 4 0 91693223 0 2097370 0 31 0 49 0 15 0 307991771 0 140516 0 6 0 4103 0 179 0 1 0 13 0 468910091 0 468961 0 5 0 510 0 50097157 0 4346 0 32699 0
result:
points 0.5 right answer but not right solutions at 23th solution
Test #23:
score: 0
Wrong Answer
time: 143ms
memory: 7828kb
input:
6 23 1000 10 0 978686021 287986921 276311856 889616598 739968417 1060147652 463275477 172393699 591333230 983197307 235514434 330494755 449056272 882229818 781111474 275587745 980041928 334198691 305313012 415758352 947298893 950211162 909723054 961622596 917454340 161928901 404346316 369133631 1038...
output:
709905 0 1148 0 199214 0 920 0 3412 0 51 0 1 1 0 12155683 0 524287 0 27 0 7669 0 2 0 1163 0 1399949 0 26291797 0 669663 0 18 0 121 0 492112602 0 3990400 0 2 0 65535 0 7178 0
result:
wrong answer used stones does not equal to outputed k
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #7:
0%
Subtask #9:
score: 0
Skipped
Dependency #8:
0%