# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
642393 | manizare | Kpart (eJOI21_kpart) | C++14 | 1954 ms | 198200 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define pb push_back
#pragma GCC target ("avx")
#pragma GCC optimaze ("unroll-loops")
using namespace std ;
const int maxn = 1e5 + 10 , maxq = 1e3+10 , mod = 998244353 ,inf = 1e9 ;
int a[maxn] ;
short dp[maxq][maxn] ;
int pre[maxn] ;
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t ;
cin >> t ;
while(t--){
int n ;
cin >> n ;
for(int i =1 ; i<= n ; i++){
cin >> a[i] ;
pre[i] = pre[i-1] + a[i] ;
}
memset(dp , 0 , sizeof dp);
dp[0][0] = 0 ;
for(int i = 1; i <= n ; i++){
for(int j = 0 ; j <= pre[i] ; j++){
dp[i][j] = dp[i-1][j] ;
if(a[i] <= j){
dp[i][j] = max(dp[i-1][j-a[i]] , dp[i][j]);
}
if(j == a[i] && j != 0)dp[i][j] = i ;
else if(dp[i][j] == 0 && j == 0)dp[i][j] =0 ;
}
}
vector <int> v;
for(int i =1 ;i <= n ; i++){
int x = 1 , ok = 0;
for(int j = i ; j <= n ; j++){
int sum = pre[j] - pre[x-1] ;
if(sum % 2 == 1 || dp[j][sum/2] < x || dp[j][sum/2] == -1){
ok = 1;
break;
}
x++;
}
if(ok == 0)v.pb(i);
}
cout << v.size() << " " ;
for(short i = 0 ; i <v.size();i++)cout << v[i] << " " ;
cout << "\n";
}
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... |