Submission #632124

#TimeUsernameProblemLanguageResultExecution timeMemory
632124Jovan26Kpart (eJOI21_kpart)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; int sum(int a[],int x, int y){ int s = 0; for(int i=x;i<y;i++) s+=a[i]; return s; } bool podeli(int a[], int x, int y){ int b[33]; for(int i=0;i<33;i++) b[i] = 0; for(int i=x;i<y;i++) b[i]=a[i]; sort(b+x,b+y); int s = sum(b,x,y); if(s%2==1) return false; int l = x; int r = x+1; while(r>l && r<=y){ if(sum(b,l,r)==s/2) return true; else if(sum(b,l,r)>s/2) l++; else if(sum(b,l,r)<s/2) r++; } return false; } 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:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int j=0;j<u[i].size();j++){
      |              ~^~~~~~~~~~~~
Main.cpp:59:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   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...