QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#72930#4377. BackpackpoiWA 215ms3936kbC++1.2kb2023-01-20 14:06:522023-01-20 14:06:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-20 14:06:53]
  • 评测
  • 测评结果:WA
  • 用时:215ms
  • 内存:3936kb
  • [2023-01-20 14:06:52]
  • 提交

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[1023];

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: 215ms
memory: 3936kb

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:

1023
0
0
1023
1023
1023
1023
1023
1023
1023

result:

wrong answer 1st lines differ - expected: '1021', found: '1023'