Submission #537606

#TimeUsernameProblemLanguageResultExecution timeMemory
537606tqbfjotldKpart (eJOI21_kpart)C++14
30 / 100
2098 ms644 KiB
#include <bits/stdc++.h> using namespace std; int pre[1005]; int arr[1005]; bool can[1005][1005]; int main(){ int TC; scanf("%d",&TC); while (TC--){ int n; scanf("%d",&n); for (int x = 0; x<n; x++){ scanf("%d",&arr[x]); if (x==0) pre[x] = arr[x]; else pre[x] = arr[x]+pre[x-1]; } for (int x = 0; x<n; x++){ bitset<50005> bs; bs[0] = true; for (int y = x; y<n; y++){ bs = bs | (bs<<arr[y]); int sm = pre[y]-(x==0?0:pre[x-1]); //printf("tt %d\n",sm); if (sm&1) can[x][y] = false; else can[x][y] = bs[sm/2]; //printf("can %d %d = %d\n",x,y,can[x][y]); } } vector<int> ans; for (int x = 1; x<=n; x++){ bool t = true; for (int y = 0; y+x<=n; y++){ if (!can[y][y+x-1]){ t = false; break; } } if (t) ans.push_back(x); } printf("%d ",ans.size()); for (auto x : ans) printf("%d ",x); printf("\n"); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:42:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   42 |         printf("%d ",ans.size());
      |                 ~^   ~~~~~~~~~~
      |                  |           |
      |                  int         std::vector<int>::size_type {aka long unsigned int}
      |                 %ld
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&TC);
      |     ~~~~~^~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
Main.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf("%d",&arr[x]);
      |             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...