QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50688#4377. BackpackchenshigeRE 0ms0kbC++654b2022-09-28 17:08:332022-09-28 17:08:35

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-28 17:08:35]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-09-28 17:08:33]
  • 提交

answer

// Nothing is Given, Everything is Earned.
#include<bits/stdc++.h>
using namespace std;

int main()
{
   int T; cin>>T;
   while(T--)
   {
      static const int N=1024;
      int n,m,a[n+1],b[n+1];
      bitset<N> f[n+1][n+1];
      scanf("%d%d",&n,&m);
      for(int i=1;i<=n;i++) scanf("%d%d",a+i,b+i);
      f[0][0][0]=1;
      for(int i=1;i<=n;i++)
      {
         for(int j=0;j<1024;j++)
         {
            f[i][j]=(f[i-1][j]|f[i-1][j^b[i]]<<a[i]);
         }
      }
      int ans=-1;
      for(int i=1023;~i;i--)
      {
         if(f[n][i][m]) ans=max(ans,i);
      }
      cout<<ans<<endl;
   }
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: