제출 #1058646

#제출 시각아이디문제언어결과실행 시간메모리
1058646NickpapadakKpart (eJOI21_kpart)C++14
0 / 100
56 ms348 KiB
#include<bits/stdc++.h> using namespace std; int T; void BruteForce(){ while(T--){ int N; scanf("%d", &N); int a[N+2], p[N+2]; p[0] = 0; for(int i = 1; i<=N;++i){ scanf("%d", &a[i]); p[i] = p[i-1] + a[i]; } queue<int> ans; for(int k = 2; k<= N; ++k){ bool ok = true; for(int i = 1; i+k-1 <= N;++i){ int sm = (p[i+k-1]-p[i-1]); if(sm % 2 == 1){ ok = false; break; } // set<int> prev; // prev.insert(0); // set<int> next; // for(int j = i; j<= i+k-1; ++j){ // for(int num: prev){ // next.insert(num+a[j]); // } // prev = next; // } int suba[k+2], subap[k+2]; subap[0] = 0; for(int j= 1; j<= k; ++j){ suba[j] = a[j+i-1]; } sort(suba+1, suba+k+1); for(int j=1; j<=k; ++j) subap[j] = subap[j-1] + suba[j]; ok = false; for(int j = 1; j<= k; ++j){ for(int l = j; l <= k; ++l){ if(subap[l]-subap[j-1] == (sm>>1)) ok = true; // if(k==6) printf("%d %d:%d %d\n",l,j ,subap[l]-subap[j-1], (sm>>1)); if(subap[l]-subap[j-1] > (sm>>1)) break; } } if(!ok) break; // if(prev.count((sm>>1)) == 0){ // ok = false; // break; // } } if(ok) ans.push(k); } // printf("\n"); printf("%ld", ans.size()); while(!(ans.empty())){ printf(" %d", ans.front());ans.pop(); } printf("\n"); } } int main(){ scanf("%d", &T); BruteForce(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void BruteForce()':
Main.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
Main.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |             scanf("%d", &a[i]);
      |             ~~~~~^~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |     scanf("%d", &T);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...