Submission #632191

#TimeUsernameProblemLanguageResultExecution timeMemory
632191Jovan26Kpart (eJOI21_kpart)C++14
0 / 100
1014 ms492 KiB
#include<bits/stdc++.h> using namespace std; bool podeli(int arr[], int x,int y) { int totalSum = 0, i; for(i=x; i<y; i++) totalSum += arr[i]; // if sum is odd then does not exist. if( (totalSum & 1) != 0) return false; // Sum of each part. int partSum = totalSum/2; // latest compilers allows variable length arrays. // Else declare the array on heap bool partArr[partSum+1][33]; // initialize top row as true for (i = x; i <= y; i++) partArr[0][i] = true; // initialize first column as false (except part[0][0]) for (i = 1; i <= partSum; i++) partArr[i][0] = false; // Fill the partition table in botton up manner for (i = x+1; i <= partSum; i++) { for (int j = x+1; j <= y; j++) { partArr[i][j] = partArr[i][j-1]; if (i >= arr[j-1]) partArr[i][j] = partArr[i][j] || partArr[i - arr[j-1]][j-1]; } } return partArr[partSum][y]; } int main(){ int t; cin>>t; vector<int> u[t]; for(int e = 0; e<t;e++){ int n; cin>>n; int a[n]; int br[n+1]; for(int i=0;i<n;i++){ cin>>a[i]; br[i] = 0; } br[n] = 0; for(int i=2;i<=n;i++){ for(int j=0;j<=n-i;j++){ if(podeli(a,j,j+i)){ br[i]++; } } } int rez = 0; for(int i=2;i<=n;i++){ if(br[i]==n-i+1){ rez++; } } u[e].push_back(rez); for(int i=2;i<=n;i++) { if(br[i]==n-i+1) u[e].push_back(i); } } for(int i=0;i<t;i++){ for(int j=0;j<u[i].size();j++){ cout<<u[i][j]; if(j!=u[i].size()-1) cout<<" "; } if(i!=t-1) cout<<endl; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:67:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |  for(int j=0;j<u[i].size();j++){
      |              ~^~~~~~~~~~~~
Main.cpp:69:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   if(j!=u[i].size()-1) cout<<" ";
      |      ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...