Submission #539064

#TimeUsernameProblemLanguageResultExecution timeMemory
539064ddy888Kpart (eJOI21_kpart)C++17
30 / 100
2084 ms172080 KiB
// #undef _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // #define fi first // #define si second // #define ar array // typedef pair<int,int> pi; // typedef tuple<int,int,int> ti; // void debug_out() {cerr<<endl;} // template <typename Head, typename... Tail> // void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);} // #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) inline void read(int& x) { x = 0; char ch = getchar_unlocked(); while (ch < '0' || ch > '9') ch = getchar_unlocked(); while (ch >= '0' && ch <= '9' ) { x = (x << 3) + (x << 1) + (ch & 15); ch = getchar_unlocked(); } } int T; int N; int main() { read(T); while (T--) { read(N); vector<int> A(N + 1), ps(N + 1); for (int i = 1; i <= N; ++i) { read(A[i]); ps[i] = ps[i - 1] + A[i]; } vector<vector<int> > dp(N + 1, vector<int>(50100)); for (int en = 1; en <= N; ++en) { dp[en][0] = en; if (A[en] <= 50000) dp[en][A[en]] = en; for (int value = 1; value <= 50000; ++value) { if (value >= A[en]) dp[en][value] = max(dp[en - 1][value - A[en]], dp[en - 1][value]); else dp[en][value] = dp[en - 1][value]; } } vector<int> cannot(N + 1); int ans = 0; for (int k = 1; k <= N; ++k) { for (int i = 1; i <= N - k + 1; ++i) { int sum = ps[i + k - 1] - ps[i - 1]; if (sum % 2 != 0) {cannot[k] = 1; break;} else if (dp[i + k - 1][sum / 2] < i) {cannot[k] = 1; break;} } if (!cannot[k]) ++ans; } cout << ans << ' '; for (int i = 1; i <= N; ++i) if (!cannot[i]) cout << i << ' '; cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...