QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#41323#4377. Backpack01shijian#WA 603ms4728kbC++171.3kb2022-07-29 16:03:442022-07-29 16:03:47

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 16:03:47]
  • 评测
  • 测评结果:WA
  • 用时:603ms
  • 内存:4728kb
  • [2022-07-29 16:03:44]
  • 提交

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 = 2050;

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 < (1 << 10); 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 603ms
memory: 4728kb

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'