QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#41320 | #4377. Backpack | 01shijian# | WA | 318ms | 3904kb | C++17 | 1.3kb | 2022-07-29 15:40:20 | 2022-07-29 15:40:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include <debugger>
clock_t start = clock();
#else
#define debug(...) 42
#endif
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
constexpr int N = 1030;
bitset<N> f[N];
bitset<N> g[N];
// bitset<N> now[N];
int main() {
// freopen("1.out", "w", stdout);
cin.tie(nullptr)->sync_with_stdio(false);
auto solve = [&] () {
int n, m; cin >> n >> m;
for(int i = 0; i < N; i ++ ) f[i].reset(), g[i].reset();
//f[j]表示价值为j的时候的所有体积和
f[0][0] = 1, g[0][0] = 1;
for(int i = 0; i < n; i ++ ) {
int v, w; cin >> v >> w;
// for(int j = 0; j < N; j ++ ) g[j] = f[j];
for(int j = 0; j < N; j ++ ) {
g[j ^ w] |= (f[j] << v);
}
for(int j = 0; j < N; j ++ ) {
f[j] = g[j];
}
}
for(int i = N - 1; i > 0; i -- ) if(f[i][m]) {
cout << i << "\n";
return ;
}
cout << "1\n";
};
int T; cin >> T;
while (T --) {
solve();
}
#ifdef LOCAL
clock_t ends = clock();
cout << "\n\nRunning Time : " << (double) (ends - start) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
#endif
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 318ms
memory: 3904kb
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'