Submission #905884

# Submission time Handle Problem Language Result Execution time Memory
905884 2024-01-13T06:19:24 Z Faisal_Saqib Bali Sculptures (APIO15_sculpture) C++17
37 / 100
56 ms 788 KB
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
const ll inf=1e18;
const ll N=200;
ll aps[N];
ll pre[N];
ll dp[N][N];
bool posp[N][N];
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>aps[i];
		pre[i+1]=aps[i]+pre[i];
	}
	ll pos=(1ll<<21)-1;
	for(int i=20;i>=0;i--)
	{
		ll new_pos=pos-(1ll<<i);
		// Can i spilt the array in segement so that the final_or let that be b so that the bit off in pos are off  in b
		// dp[i][j] let spilt the prefix i into j part so what is the minimum or possible
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				dp[i][j]=inf;
		for(int i=0;i<=n;i++)
			for(int j=0;j<=n;j++)
				posp[i][j]=0;
		dp[0][0]=0;
		posp[0][0]=1;
		bool pos1=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=i;j++)
			{
				for(int k=0;k<i;k++)
				{
					if(posp[k][j-1])
					{
						bool das=1;
						ll np=(dp[k][j-1]|(pre[i]-pre[k]));
						for(int bit=20;bit>=0;bit--)
						{
							if((np&(1<<bit))>((new_pos&(1<<bit))))
							{
								das=0;
							}
						}
						if(das)
						{
							dp[i][j]=min(dp[i][j],(dp[k][j-1]|(pre[i]-pre[k])));
							posp[i][j]=1;
						}
					}
				}
				if(i==n and a<=j and j<=b and posp[i][j])
				{
					pos1=1;
				}
			}
		}
		if(pos1)
			pos=new_pos;
	}
	cout<<pos<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 428 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Incorrect 1 ms 348 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 500 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 376 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 6 ms 344 KB Output is correct
31 Correct 8 ms 528 KB Output is correct
32 Correct 8 ms 540 KB Output is correct
33 Correct 9 ms 344 KB Output is correct
34 Correct 8 ms 348 KB Output is correct
35 Correct 8 ms 348 KB Output is correct
36 Correct 10 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 372 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 9 ms 532 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 8 ms 348 KB Output is correct
21 Correct 8 ms 344 KB Output is correct
22 Correct 10 ms 348 KB Output is correct
23 Correct 8 ms 788 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 15 ms 564 KB Output is correct
26 Correct 30 ms 348 KB Output is correct
27 Correct 39 ms 584 KB Output is correct
28 Correct 51 ms 600 KB Output is correct
29 Correct 49 ms 604 KB Output is correct
30 Correct 56 ms 600 KB Output is correct
31 Correct 53 ms 616 KB Output is correct
32 Correct 50 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 476 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Incorrect 1 ms 344 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Incorrect 1 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -