QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#47481 | #4377. Backpack | neko_nyaa# | WA | 181ms | 3660kb | C++ | 907b | 2022-09-10 10:31:58 | 2022-09-10 10:31:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll modpow(ll n, ll k) {
ll ans = 1;
for (; k; n = n * n % mod, k /= 2)
if (k & 1) ans = ans * n % mod;
return ans;
}
#define int long long
void solve() {
int n, m; cin >> n >> m;
vector<bitset<1024>> dp(1024);
// dp[xorsum][capacity]
dp[0][0] = 1;
while (n--) {
int v, w; cin >> v >> w;
for (int i = 0; i < 1024; i++) {
int j = i^w;
if (j > i) continue;
bitset<1024> ni = dp[i] | (dp[j] << v);
bitset<1024> nj = dp[j] | (dp[i] << v);
dp[i] = ni;
dp[j] = nj;
}
}
int ans = -1;
for (int i = 0; i < 1024; i++) {
if (dp[i][m]) ans = i;
}
if (ans == -1) {
ans = 1;
}
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 181ms
memory: 3660kb
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 1023 1023 1023 1023 1023 1023 513
result:
wrong answer 3rd lines differ - expected: '-1', found: '1'