QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#614439#4377. BackpackSSAABBEERRWA 354ms7924kbC++20803b2024-10-05 16:21:382024-10-05 16:21:39

Judging History

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

  • [2024-10-05 16:21:39]
  • 评测
  • 测评结果:WA
  • 用时:354ms
  • 内存:7924kb
  • [2024-10-05 16:21:38]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define pre(x,a,b) for(int x=a;x>=b;x--)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 1e6 + 10;
int n, m;
int v[N], w[N];
bitset<1500>f[2][1500];
void solve()
{   
	cin >> n >> m;
	rep(i, 1, n)
	{
		cin >> v[i] >> w[i];
	}
	rep(i, 0, 1400)
	{
		rep(j, 0, 1)
		f[j][i].reset();
	}
	f[0][0][0] = 1;
	rep(i, 1, n)
	{
		rep(j, 0, 1200)
		{
			f[1][j] = f[0][j];
			f[1][j] |= (f[0][j ^ w[i]] << v[i]);
		}
		rep(j, 0, 1200)
		{
			f[0][j] = f[1][j];
		}
	}
	int ans = -1;
	rep(i, 0, 1200) if(f[1][i][m]) ans = i;
	cout << ans << endl;
}
int main()
{
    IOS;
	int _;
	_ = 1;
	cin >> _;
	while(_--)
	{
	    solve();
	}
	return 0;
}       

詳細信息

Test #1:

score: 0
Wrong Answer
time: 354ms
memory: 7924kb

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:

1197
1200
-1
1200
1200
1200
1200
1200
1200
1117

result:

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