답안 #839631

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839631 2023-08-30T10:57:18 Z Dzadzo Kpart (eJOI21_kpart) C++
30 / 100
2000 ms 3044 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define S second
#define F first
#define pii pair<int,int>
#define vi vector <int>
#define vvi vector <vi>
#define vvvi vector <vvi>
#define INF LLONG_MAX
#define MOD 1000000009
#define MAXN 100000
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
int32_t main() {
	int t;
	scanf("%d",&t);
	while (t--){
		int n;
		scanf("%d",&n);
		int a[n+1];
		int p[n+1];
		p[0]=0;
		for (int i=1;i<=n;i++){scanf("%d",&a[i]);p[i]=p[i-1]+a[i];}
		bitset<50001>b[n];
		for (int i=1;i<n;i++)b[i][0]=1;
		for (int i=1;i<n;i++){
			b[i] |= (b[i]<<a[i]);
		}
		vi ans;
		for (int k=2;k<=n;k++){
			bool check=true;
			for (int i=k;i<=n;i++){
				b[i-k+1] |= (b[i-k+1]<<a[i]);
				if ((p[i]-p[i-k])%2!=0){check=false;}else
				if (!b[i-k+1][(p[i]-p[i-k])/2])check=false;
			}
			if (check)ans.pb(k);
		}
		printf("%lu",ans.size());
		for (int x:ans)printf(" %d",x);
		printf("\n");
	}
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d",&t);
      |  ~~~~~^~~~~~~~~
Main.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
Main.cpp:31:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   for (int i=1;i<=n;i++){scanf("%d",&a[i]);p[i]=p[i-1]+a[i];}
      |                          ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 716 KB Output is correct
2 Correct 142 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 654 ms 1836 KB Output is correct
2 Correct 1756 ms 2648 KB Output is correct
3 Execution timed out 2031 ms 3044 KB Time limit exceeded
4 Halted 0 ms 0 KB -