Submission #1105001

#TimeUsernameProblemLanguageResultExecution timeMemory
1105001KasymKKpart (eJOI21_kpart)C++17
10 / 100
2055 ms444 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a, T b) { return a > b ? a = b, 1 : 0; } template<class T>bool umax(T& a, T b) { return a < b ? a = b, 1 : 0; } bool is(deque<int> &dq){ int wow = accumulate(all(dq), 0); if(wow&1) return 0; vector<bool> dp(wow+1, false); dp[0] = 1; for(int &to : dq) for(int i = wow; i >= to; --i) if(dp[i-to]) dp[i] = 1; return dp[wow/2]; } int main(){ int t; scanf("%d", &t); while(t--){ int n; scanf("%d", &n); vector<int> v(n+1); for(int i = 1; i <= n; ++i){ int x; scanf("%d", &x); v[i] = x; } vector<int> A; for(int k = 2; k <= n; ++k){ deque<int> dq; bool ok = 1; for(int i = 1; i <= k; ++i) dq.pb(v[i]); ok &= is(dq); for(int i = k+1; i <= n; ++i){ dq.pb(v[i]); dq.pop_front(); ok &= is(dq); } if(ok) A.pb(k); } printf("%d ", (int)A.size()); tr(it, A) printf("%d ", *it); puts(""); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d", &t);
      |     ~~~~~^~~~~~~~~~
Main.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
Main.cpp:38:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...