QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#664137 | #4377. Backpack | SSAABBEERR | WA | 382ms | 4696kb | C++20 | 1012b | 2024-10-21 19:21:32 | 2024-10-21 19:21:33 |
Judging History
answer
#include<bits/stdc++.h>
#define endl "\n"
#define int long long
using namespace std;
#define pii pair<int, int>
#define rep(i, a, b) for(int i = a; i <= b; i ++ )
#define pre(i, a, b) for(int i = a; i >= b; i -- )
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int N = 1e6 + 10;
int n, m, k;
bitset<2024>dp[2][2024];
void solve()
{
cin >> n >> m;
rep(i, 0, 2000) dp[0][i].reset(), dp[1][i].reset();
dp[0][0] = 1;
dp[1][0] = 1;
rep(i, 1, n)
{
int v, w;
cin >> v >> w;
if(i==1)continue;
rep(j, 0, 1030)
{
dp[1][j] |= (dp[0][j ^ w] << v);
}
// if(i==1)cout<<dp[1][4];
rep(j, 0, 1030) dp[0][j] = dp[1][j];
}
int ans = -1;
rep(i, 0, 1030)
{
if(dp[0][i][m]) ans = i;
}
cout << ans << endl;
}
signed main()
{
IOS;
int _;
_ = 1;
cin >> _;
while(_ -- )
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 382ms
memory: 4696kb
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 1030 1030 1030 1030 1030 1030 513
result:
wrong answer 4th lines differ - expected: '1023', found: '1030'