답안 #890149

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890149 2023-12-20T15:48:35 Z kim Kpart (eJOI21_kpart) C++17
0 / 100
565 ms 101256 KB
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define eb emplace_back

const int MX=100000;

int a[1005],qs[1005];
int dp[1005][MX+5];

void solve(){
	int n; cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		qs[i]=a[i]+qs[i-1];
		for(int j=0;j<=MX;++j) dp[i][j]=0;
	}
	vector<bool> ok(n+5,1);
	for(int i=1;i<=n;++i){
		dp[i][a[i]]=1;
		for(int j=0;j<=MX;++j){
			if(!dp[i-1][j]) continue;
			dp[i][j]+=dp[i-1][j];
			if(j+a[i]<=MX) dp[i][j+a[i]]+=dp[i-1][j];
		}
		for(int j=1,k=i;j<i;++j,--k){
			if((qs[i]-qs[j-1])&1) ok[k]=0;
			if(!ok[k]) continue;
			if(dp[i][qs[i]-qs[j-1]>>1]-dp[j-1][qs[i]-qs[j-1]>>1]) continue;
			ok[k]=0;
		}
	}
	vector<int> ans;
	for(int i=2;i<=n;++i){
		if(ok[i]) ans.eb(i);
	}
	cout<<ans.size()<<" ";
	for(auto &e:ans) cout<<e<<" ";
	cout<<endl;

}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int Q(1);
	cin>>Q;
	dp[0][0]=1;
	while(Q--){
		solve();
	}

	return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:29:18: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   29 |    if(dp[i][qs[i]-qs[j-1]>>1]-dp[j-1][qs[i]-qs[j-1]>>1]) continue;
      |             ~~~~~^~~~~~~~
Main.cpp:29:44: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   29 |    if(dp[i][qs[i]-qs[j-1]>>1]-dp[j-1][qs[i]-qs[j-1]>>1]) continue;
      |                                       ~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 12636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 152 ms 26972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 565 ms 101256 KB Output isn't correct
2 Halted 0 ms 0 KB -