QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#72931 | #4377. Backpack | poi | WA | 211ms | 3932kb | C++ | 1.2kb | 2023-01-20 14:08:07 | 2023-01-20 14:08:11 |
Judging History
answer
#include "iostream"
#include "cstring"
#include "cstdio"
#include "algorithm"
#include "queue"
#include "vector"
#include "queue"
#include "stack"
#include "ctime"
#include "set"
#include "map"
#include "bitset"
using namespace std;
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define rep( i , a , b ) for( int i = (a) , i##end = b ; i <= i##end ; ++ i )
#define per( i , a , b ) for( int i = (a) , i##end = b ; i >= i##end ; -- i )
#define mem( a ) memset( a , 0 , sizeof (a) )
#define all( x ) x.begin() , x.end()
//#define int long long
typedef long long ll;
const int MAXN = 26 + 10;
const int P = 998244353;
int n , m , k;
bitset<1024> dp[1030] , pd[1026];
void solve() {
cin >> n >> m;
rep( i , 0 , 1023 ) dp[i].reset( );
dp[0][0] = 1;
rep( i , 1 , n ) {
int v , w;
scanf("%d%d",&v,&w);
rep( j , 0 , 1023 ) pd[j] = dp[j];
rep( j , 0 , 1023 ) dp[j] |= ( pd[j ^ w] << v );
}
int res = 0;
rep( k , 0 , 1023 ) if( dp[k][m] ) res = k;
cout << res << endl;
}
signed main() {
// freopen("in","r",stdin);
// freopen("out","w",stdout);
int T;cin >> T;while( T-- ) solve();
// solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 211ms
memory: 3932kb
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 0 1023 1023 1023 1023 1023 1023 513
result:
wrong answer 3rd lines differ - expected: '-1', found: '0'