QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100822#4377. Backpacksyzf2222WA 258ms3812kbC++14733b2023-04-28 11:23:392023-04-28 11:23:41

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-28 11:23:41]
  • 评测
  • 测评结果:WA
  • 用时:258ms
  • 内存:3812kb
  • [2023-04-28 11:23:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int mod=1e9+7;
#define inf 1e9
inline int read(){
	int 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<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}
bitset<1025>F[2][1025];
int n,m,T;
int main(){
	T=read();
	while(T--){
		n=read(),m=read();
		for(int i=0;i<1024;i++)
			F[0][i].reset(),F[1][i].reset();
		F[0][0][0]=1;
		for(int i=1;i<=n;i++){
			int o=(i&1),u=read(),v=read();
			for(int j=0;j<1024;j++)
				F[o][j]=F[o^1][j]|(F[o^1][j^v]<<u);
		}int flg=0;
		for(int i=1023;i>=0;--i)
			if(F[n&1][i][m]){printf("%d\n",i);flg=1;break;}
		if(!flg)puts("1");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 258ms
memory: 3812kb

input:

10
1023 401
179 441
416 951
420 984
1013 984
683 914
407 984
96 523
374 190
974 190
739 441
518 523
194 984
415 523
149 441
235 984
809 441
469 441
436 919
437 919
7 919
818 984
962 190
37 919
371 523
417 914
431 914
213 190
340 441
254 919
223 951
123 190
339 951
322 441
218 441
284 919
533 190
187...

output:

1021
1011
1
1023
1023
1023
1023
1023
1023
513

result:

wrong answer 3rd lines differ - expected: '-1', found: '1'