# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
632460 | pragmatist | Kpart (eJOI21_kpart) | C++17 | 2079 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(v) (int)v.size()
#define nl "\n"
using namespace std;
const int N = (int)31;
const int M = (int)1e5 + 7;
int n, a[N];
bitset<M> dp;
void solve() {
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i];
vector<int> ans;
for(int k = 2; k <= n; ++k) {
bool ok = 1;
for(int i = 1; i <= n - k + 1; ++i) {
dp.reset();
dp[0] = 1;
bool cur = 0;
int sum = 0;
for(int j = i; j <= i + k - 1; ++j) {
sum += a[j];
dp |= dp << a[j];
}
if(sum & 1) {
ok = 0;
break;
}
if(!dp[sum / 2]) {
ok = 0;
break;
}
}
if(ok) ans.pb(k);
}
cout << sz(ans) << ' ';
for(auto x : ans) cout << x << ' ';
cout << nl;
}
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int test;
cin >> test;
while(test--) {
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |