QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#41321#4377. Backpack01shijian#WA 379ms4008kbC++171.3kb2022-07-29 15:48:512022-07-29 15:48:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-29 15:48:52]
  • 评测
  • 测评结果:WA
  • 用时:379ms
  • 内存:4008kb
  • [2022-07-29 15:48:51]
  • 提交

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: 379ms
memory: 4008kb

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'