Submission #1058567

#TimeUsernameProblemLanguageResultExecution timeMemory
1058567NickpapadakKpart (eJOI21_kpart)C++14
10 / 100
2062 ms1016 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; } if(prev.count((sm>>1)) == 0){ ok = false; break; } } if(ok) ans.push(k); } printf("%ld", ans.size()); while(!(ans.empty())){ printf(" %d", ans.front());ans.pop(); } printf("\n"); } } int main(){ scanf("%d", &T); BruteForce(); return 0; }

Compilation message (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:53:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     scanf("%d", &T);
      |     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...