Submission #582593

#TimeUsernameProblemLanguageResultExecution timeMemory
582593juggernautKpart (eJOI21_kpart)C++14
30 / 100
177 ms340 KiB
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; typedef long long ll; typedef long double ld; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef juggernaut #define printl(args...) printf(args) #else #define printl(args...) 0 #endif bool can[125]; int a[125]; bitset<50005>dp; int main(){ int test; scanf("%d",&test); while(test--){ int n; scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=n;i++)can[i]=1; for(int i=1;i<=n;i++){ dp=0; dp[0]=1; int sum=0; for(int j=i;j<=n;j++){ sum+=a[j]; dp|=(dp<<a[j]); if((sum&1)||(!dp[sum>>1]))can[j-i+1]=0; } } int cnt=0; for(int i=1;i<=n;i++)cnt+=can[i]; printf("%d ",cnt); for(int i=1;i<=n;i++)if(can[i])printf("%d ",i); printf("\n"); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  scanf("%d",&test);
      |  ~~~~~^~~~~~~~~~~~
Main.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
Main.cpp:29:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   for(int i=1;i<=n;i++)scanf("%d",&a[i]);
      |                        ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...