QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#47974 | #4377. Backpack | zzxzzx123 | WA | 101ms | 4028kb | C++17 | 650b | 2022-09-10 21:39:15 | 2022-09-10 21:39:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
bitset<N>dp[N],f[N];
int n,m;
int w[N],v[N];
int main(){
int t;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d%d",&v[i],&w[i]);
}
for(int i=0;i<=m;i++){
dp[i].reset();
}
dp[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=m;j++){
f[j]=dp[j];
}
for(int j=0;j<=m;j++){
dp[j^w[i]]|=(f[j]<<v[i]);
}
}
int ans=0;
for(int i=1;i<=(1<<10);i++){
if(dp[i][m]){
ans=max(ans,i);
}
}
if(ans){
printf("%d\n",ans);
}else {
puts("-1");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 101ms
memory: 4028kb
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:
951 1023 1023 1023 1023 1023 1023 1023 1023 1023
result:
wrong answer 1st lines differ - expected: '1021', found: '951'