QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664158#4377. BackpackSSAABBEERRWA 380ms4720kbC++20979b2024-10-21 19:24:582024-10-21 19:24:59

Judging History

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

  • [2024-10-21 19:24:59]
  • 评测
  • 测评结果:WA
  • 用时:380ms
  • 内存:4720kb
  • [2024-10-21 19:24:58]
  • 提交

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, 2023) 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);
        }
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 380ms
memory: 4720kb

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'