# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
560202 |
2022-05-11T07:08:29 Z |
illyakr |
Kpart (eJOI21_kpart) |
C++14 |
|
2000 ms |
488 KB |
//#pragma GCC optimize("inline,Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,avx,abm")
#include <bits/stdc++.h>
#define ll long long
//#define int ll
typedef long double ld;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define y0 dfgoert
#define y1 kjsjofd
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1000000007;
const int INF1e9 = 1010101010;
const int INF1e18 = 1010101010101010101;
const ld PI = 3.14159265358979323846264338327950288419716939937510;
int n;
int a[101010];
bitset<50001> id;
bool can[101010];
void solve() {
cin >> n;
for (int i = 1; i <= n; i++)cin >> a[i];
for (int i = 1; i <= n; i++)can[i] = true;
vector<int> ans;
for (int i = 1; i <= n; i++) {
id = 0;
id[0] = 1;
int sum = 0;
for (int j = i; j <= n; j++) {
id |= (id << a[j]);
sum += a[j];
if (sum % 2 != 0) {can[j - i + 1] = false;continue;}
if (!id[sum / 2]) {can[j - i + 1] = false;continue;}
}
}
for (int i = 1; i <= n; i++) {
if (!can[i])continue;
ans.push_back(i);
}
cout << ans.size();
for (int i : ans)cout << " " << i;
cout << '\n';
}
int32_t main() {
fast
int t = 1;
cin >> t;
for (int id = 1; id <= t; id++) {
// cout << "Case " << id << ": ";
solve();
}
}
/**
6
2 3 5 1 8 3
*/
Compilation message
Main.cpp:14:21: warning: overflow in conversion from 'long int' to 'int' changes value from '1010101010101010101' to '1448443573' [-Woverflow]
14 | const int INF1e18 = 1010101010101010101;
| ^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
340 KB |
Output is correct |
2 |
Correct |
192 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
830 ms |
340 KB |
Output is correct |
2 |
Execution timed out |
2070 ms |
488 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |