QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664065#4377. BackpackSSAABBEERRWA 743ms4684kbC++201012b2024-10-21 19:06:412024-10-21 19:06:42

Judging History

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

  • [2024-10-21 19:06:42]
  • 评测
  • 测评结果:WA
  • 用时:743ms
  • 内存:4684kb
  • [2024-10-21 19:06:41]
  • 提交

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, 2000) 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, 2000)
        {
            dp[1][j] |= (dp[0][j ^ w] << v);
        }
        // if(i==1)cout<<dp[1][4];
        rep(j, 0, 2000) 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: 743ms
memory: 4684kb

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
1025
-1
1030
1030
1030
1030
1030
1030
513

result:

wrong answer 2nd lines differ - expected: '1011', found: '1025'