답안 #106841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106841 2019-04-20T17:08:47 Z Diuven Bali Sculptures (APIO15_sculpture) C++14
0 / 100
3 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;

int _min(int x, int y){ return x<y ? x : y; }

int n, l, r;
int A[2010], S[2010];

int solve1(){
	int D[2010]; lint obj = (1LL<<42LL)-1;
	for(int b=41; b>=0; b--){
		D[0] = 0; obj ^= (1LL<<lint(b));
		for(int i=1; i<=n; i++){
			D[i] = INF;
			for(int k=0; k<i; k++){
				if(((S[i]-S[k])|obj) != obj) continue;
				// if not valid, continue;
				// if 0s in obj not show in S[i]-S[k]; 
				D[i] = _min(D[i], D[k] + 1);
			}
		}
		if(D[n]==INF) obj |= (1<<b);
	}
	return obj;
}

int solve2(){
	bool D[101][101];
	lint obj = (1LL<<42LL)-1;
	for(int b=41; b>=0; b--){
		obj ^= (1LL<<lint(b));
		for(int i=1; i<=n; i++) D[0][i] = false;
		for(int j=1; j<=n; j++) D[j][0] = false;
		D[0][0] = true;
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				D[i][j] = false;
				for(int k=0; k<i; k++){
					D[i][j] |= D[k][j-1] && (((S[i]-S[k])|obj)==obj);
				}
			}
		}
		bool yay = false;
		for(int i=l; i<=r; i++) yay |= D[n][i];
		if(!yay) obj |= (1LL<<lint(b));
	}

	return obj;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);

	cin>>n>>l>>r;
	for(int i=1; i<=n; i++) cin>>A[i], S[i] = S[i-1] + A[i];

	cout<<(l==1 ? solve1() : solve2())<<'\n';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 3 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -