# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
538137 | jamielim | Kpart (eJOI21_kpart) | C++14 | 1620 ms | 197192 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
int t;
int n;
int arr[1005];
int pref[1005];
int dp[1005][50005];
// the latest start point so that at end point i you have a subsequence of sum j
int main(){
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&arr[i]);
pref[i]=pref[i-1]+arr[i];
}
memset(dp,-1,sizeof(dp));
for(int i=1;i<=n;i++){
dp[i][0]=i;
int m=min(pref[i],50005);
if(pref[i]<50005)dp[i][pref[i]]=1;
for(int j=1;j<m;j++){
dp[i][j]=dp[i-1][j];
if(j==arr[i])dp[i][j]=i;
if(j>arr[i])dp[i][j]=max(dp[i][j],dp[i-1][j-arr[i]]);
}
}
vector<int> ans;
for(int i=2;i<=n;i++){
bool poss=1;
for(int j=1;j<=n-i+1;j++){
int ttl=pref[j+i-1]-pref[j-1];
if(ttl%2==1){poss=0;break;}
if(dp[j+i-1][ttl/2]<j){poss=0;break;}
}
if(poss)ans.pb(i);
}
printf("%d ",SZ(ans));
for(int i:ans)printf("%d ",i);
printf("\n");
}
}
컴파일 시 표준 에러 (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... |