답안 #685223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685223 2023-01-23T17:22:27 Z tolbi Bootfall (IZhO17_bootfall) C++17
28 / 100
634 ms 262144 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
#define author tolbi
#include<bits/stdc++.h>
#define endl '\n'
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define vint(x) vector<int> x
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define revarr(x) reverse(x.begin(), x.end())
#define tol(bi) (1LL<<((int)(bi)))
#define INF LONG_LONG_MAX
using namespace std;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
const int MOD = 1e9+7;
int32_t main(){
	int T=1;
	int tno=0;
	if (!T) cin>>T;
	while (T-(tno++)){
		deci(n);
		vint(arr(n));
		cinarr(arr);
		int somma = 0; for (int i = 0; i < n; i++) somma+=arr[i];
		vector<vector<vector<bitset<512>>>> dp(n+1,vector<vector<bitset<512>>>(somma+1,vector<bitset<512>>(2)));
		vector<vector<vector<bool>>> vis(n+1,vector<vector<bool>>(somma+1,vector<bool>(2,false)));
		bitset<512> dolu;
		for (int i = 0; i < n; i++){
			dolu[i]=true;
		}
		auto f = [&](int node, int crr, int flag, auto rec)->bitset<512>{
			crr=abs(crr);
			bitset<512> rval;
			if (node==0){
				if (crr==0 && flag) return dolu;
				return rval;
			}
			if (crr>somma) return rval;
			if (vis[node][crr][flag]) return dp[node][crr][flag];
			vis[node][crr][flag]=true;
			if (flag){
				rval = (rec(node-1,crr+arr[node-1],flag,rec)|rec(node-1,crr-arr[node-1],flag,rec));
			}
			else {
				bitset<512> kk = rval;
				kk[node-1]=true;
				rval|=rec(node-1,crr-arr[node-1],flag,rec);
				rval|=rec(node-1,crr+arr[node-1],flag,rec);
				kk&=rec(node-1,crr,1,rec);
				rval|=kk;
			}
			return dp[node][crr][flag]=rval;
		};
		if (f(n,0,1,f).count()==0){
			cout<<0<<endl;
			continue;
		}
		vector<int> say;
		for (int i = 1; i < somma; i++){
			if (f(n,i,0,f).count()==n){
				say.push_back(i);
			}
		}
		cout<<say.size()<<endl;
		coutarr(say);
	}
}

Compilation message

bootfall.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      | 
bootfall.cpp: In function 'int32_t main()':
bootfall.cpp:71:26: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |    if (f(n,i,0,f).count()==n){
      |        ~~~~~~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 4 ms 3112 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 7 ms 5292 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 4 ms 3112 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 7 ms 5292 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
10 Correct 6 ms 4436 KB Output is correct
11 Correct 3 ms 2092 KB Output is correct
12 Correct 4 ms 3120 KB Output is correct
13 Correct 2 ms 1836 KB Output is correct
14 Correct 3 ms 2260 KB Output is correct
15 Correct 2 ms 1748 KB Output is correct
16 Correct 3 ms 2092 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 3 ms 1748 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 7 ms 4692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 4 ms 3112 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 7 ms 5292 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
10 Correct 6 ms 4436 KB Output is correct
11 Correct 3 ms 2092 KB Output is correct
12 Correct 4 ms 3120 KB Output is correct
13 Correct 2 ms 1836 KB Output is correct
14 Correct 3 ms 2260 KB Output is correct
15 Correct 2 ms 1748 KB Output is correct
16 Correct 3 ms 2092 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 3 ms 1748 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 7 ms 4692 KB Output is correct
21 Correct 97 ms 48588 KB Output is correct
22 Correct 121 ms 60824 KB Output is correct
23 Correct 51 ms 28608 KB Output is correct
24 Correct 192 ms 103896 KB Output is correct
25 Correct 528 ms 200856 KB Output is correct
26 Correct 634 ms 226012 KB Output is correct
27 Correct 530 ms 210928 KB Output is correct
28 Correct 603 ms 224708 KB Output is correct
29 Correct 574 ms 231656 KB Output is correct
30 Correct 237 ms 125900 KB Output is correct
31 Correct 368 ms 179928 KB Output is correct
32 Correct 242 ms 113356 KB Output is correct
33 Correct 568 ms 238484 KB Output is correct
34 Correct 605 ms 236476 KB Output is correct
35 Correct 631 ms 231216 KB Output is correct
36 Correct 198 ms 111524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 4 ms 3112 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 7 ms 5292 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
10 Correct 6 ms 4436 KB Output is correct
11 Correct 3 ms 2092 KB Output is correct
12 Correct 4 ms 3120 KB Output is correct
13 Correct 2 ms 1836 KB Output is correct
14 Correct 3 ms 2260 KB Output is correct
15 Correct 2 ms 1748 KB Output is correct
16 Correct 3 ms 2092 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 3 ms 1748 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 7 ms 4692 KB Output is correct
21 Correct 97 ms 48588 KB Output is correct
22 Correct 121 ms 60824 KB Output is correct
23 Correct 51 ms 28608 KB Output is correct
24 Correct 192 ms 103896 KB Output is correct
25 Correct 528 ms 200856 KB Output is correct
26 Correct 634 ms 226012 KB Output is correct
27 Correct 530 ms 210928 KB Output is correct
28 Correct 603 ms 224708 KB Output is correct
29 Correct 574 ms 231656 KB Output is correct
30 Correct 237 ms 125900 KB Output is correct
31 Correct 368 ms 179928 KB Output is correct
32 Correct 242 ms 113356 KB Output is correct
33 Correct 568 ms 238484 KB Output is correct
34 Correct 605 ms 236476 KB Output is correct
35 Correct 631 ms 231216 KB Output is correct
36 Correct 198 ms 111524 KB Output is correct
37 Runtime error 118 ms 262144 KB Execution killed with signal 9
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 4 ms 3112 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 7 ms 5292 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
10 Correct 6 ms 4436 KB Output is correct
11 Correct 3 ms 2092 KB Output is correct
12 Correct 4 ms 3120 KB Output is correct
13 Correct 2 ms 1836 KB Output is correct
14 Correct 3 ms 2260 KB Output is correct
15 Correct 2 ms 1748 KB Output is correct
16 Correct 3 ms 2092 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 3 ms 1748 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 7 ms 4692 KB Output is correct
21 Correct 97 ms 48588 KB Output is correct
22 Correct 121 ms 60824 KB Output is correct
23 Correct 51 ms 28608 KB Output is correct
24 Correct 192 ms 103896 KB Output is correct
25 Correct 528 ms 200856 KB Output is correct
26 Correct 634 ms 226012 KB Output is correct
27 Correct 530 ms 210928 KB Output is correct
28 Correct 603 ms 224708 KB Output is correct
29 Correct 574 ms 231656 KB Output is correct
30 Correct 237 ms 125900 KB Output is correct
31 Correct 368 ms 179928 KB Output is correct
32 Correct 242 ms 113356 KB Output is correct
33 Correct 568 ms 238484 KB Output is correct
34 Correct 605 ms 236476 KB Output is correct
35 Correct 631 ms 231216 KB Output is correct
36 Correct 198 ms 111524 KB Output is correct
37 Runtime error 118 ms 262144 KB Execution killed with signal 9
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 4 ms 3112 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 7 ms 5292 KB Output is correct
9 Correct 3 ms 1748 KB Output is correct
10 Correct 6 ms 4436 KB Output is correct
11 Correct 3 ms 2092 KB Output is correct
12 Correct 4 ms 3120 KB Output is correct
13 Correct 2 ms 1836 KB Output is correct
14 Correct 3 ms 2260 KB Output is correct
15 Correct 2 ms 1748 KB Output is correct
16 Correct 3 ms 2092 KB Output is correct
17 Correct 1 ms 1108 KB Output is correct
18 Correct 3 ms 1748 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 7 ms 4692 KB Output is correct
21 Correct 97 ms 48588 KB Output is correct
22 Correct 121 ms 60824 KB Output is correct
23 Correct 51 ms 28608 KB Output is correct
24 Correct 192 ms 103896 KB Output is correct
25 Correct 528 ms 200856 KB Output is correct
26 Correct 634 ms 226012 KB Output is correct
27 Correct 530 ms 210928 KB Output is correct
28 Correct 603 ms 224708 KB Output is correct
29 Correct 574 ms 231656 KB Output is correct
30 Correct 237 ms 125900 KB Output is correct
31 Correct 368 ms 179928 KB Output is correct
32 Correct 242 ms 113356 KB Output is correct
33 Correct 568 ms 238484 KB Output is correct
34 Correct 605 ms 236476 KB Output is correct
35 Correct 631 ms 231216 KB Output is correct
36 Correct 198 ms 111524 KB Output is correct
37 Runtime error 118 ms 262144 KB Execution killed with signal 9
38 Halted 0 ms 0 KB -