제출 #632123

#제출 시각아이디문제언어결과실행 시간메모리
632123Jovan26Kpart (eJOI21_kpart)C++14
0 / 100
2 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; 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++; } } cout<<rez<<" "; for(int i=2;i<=n;i++) { if(br[i]==n-i+1) cout<<i<<" "; } if(e!=t-1) cout<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...