Submission #1111016

#TimeUsernameProblemLanguageResultExecution timeMemory
1111016_rain_Kpart (eJOI21_kpart)C++14
100 / 100
1328 ms196484 KiB
#include<bits/stdc++.h> using namespace std; typedef long long LL; #define name "main" #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define FORD(i,a,b) for(int i=(b);i>=(a);--i) #define N 1'000 #define S 5'0000 int a[N+2],dp[N+2][S+2]; LL p[N+2]={}; int n; void giai(){ int n;scanf("%d",&n); FOR(i,1,n){ scanf("%d",&a[i]); p[i]=p[i-1]+a[i]; } int sum=p[n]/2; FOR(i,0,n) FOR(j,0,sum) dp[i][j]=0; FOR(i,1,n){ FOR(j,0,sum) dp[i][j]=dp[i-1][j]; if (a[i]<=sum) dp[i][a[i]]=i; FOR(j,a[i],sum){ dp[i][j]=max(dp[i][j],dp[i-1][j-a[i]]); } } vector<int>pont; FOR(k,1,n){ bool ok=true; FOR(j,1,n-k+1){ LL x=p[j+k-1]-p[j-1]; if (x%2==1||dp[j+k-1][x/2]<j){ ok=false; break; } } if (ok) pont.push_back(k); } printf("%d ",pont.size()); for(auto&x:pont) printf("%d ",x); printf("\n"); return; } int32_t main(){ int test;scanf("%d",&test); while(test--) giai(); exit(0); }

Compilation message (stderr)

Main.cpp: In function 'void giai()':
Main.cpp:42:11: 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 ",pont.size());
      |          ~^   ~~~~~~~~~~~
      |           |            |
      |           int          std::vector<int>::size_type {aka long unsigned int}
      |          %ld
Main.cpp:43:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   43 |  for(auto&x:pont) printf("%d ",x); printf("\n");
      |  ^~~
Main.cpp:43:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   43 |  for(auto&x:pont) printf("%d ",x); printf("\n");
      |                                    ^~~~~~
Main.cpp:16:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  int n;scanf("%d",&n);
      |        ~~~~~^~~~~~~~~
Main.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
Main.cpp: In function 'int32_t main()':
Main.cpp:48:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  int test;scanf("%d",&test);
      |           ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...