Submission #839602

# Submission time Handle Problem Language Result Execution time Memory
839602 2023-08-30T10:35:54 Z Dzadzo Kpart (eJOI21_kpart) C++14
30 / 100
2000 ms 5064 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#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;
int32_t main() {
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	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<100001>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("%d",ans.size());
		for (int x:ans)printf(" %d",x);
		printf("\n");
	}
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:41:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   41 |   printf("%d",ans.size());
      |           ~^  ~~~~~~~~~~
      |            |          |
      |            int        std::vector<int>::size_type {aka long unsigned int}
      |           %ld
Main.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d",&t);
      |  ~~~~~^~~~~~~~~
Main.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
Main.cpp:25:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   for (int i=1;i<=n;i++){scanf("%d",&a[i]);p[i]=p[i-1]+a[i];}
      |                          ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 1144 KB Output is correct
2 Correct 270 ms 1760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1205 ms 3460 KB Output is correct
2 Execution timed out 2067 ms 5064 KB Time limit exceeded
3 Halted 0 ms 0 KB -