답안 #137642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137642 2019-07-28T08:05:32 Z 임유진(#3281) Bitwise (BOI06_bitwise) C++14
30 / 100
1000 ms 508 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 105;

int main() {
	ios::sync_with_stdio(0);
	int N, P;
	int K[MAXN], A[MAXN], B[MAXN];
	int mult[MAXN];
	int sum[MAXN];
	int v[MAXN];
	int ans = 0;

	cin >> N >> P;
	for(int i = 0; i < P; i++) cin >> K[i];
	for(int i = 0; i < N; i++) cin >> A[i] >> B[i];

	mult[N] = 1;
	for(int i = N - 1; i >= 0; i--) mult[i] = mult[i + 1] * (B[i] - A[i] + 1);
	//for(int i = 0; i <= N; i++) printf("%d ", mult[i]);
	//printf("\n");
	sum[0] = 0;
	for(int i = 1; i <= P; i++) sum[i] = sum[i - 1] + K[i - 1];
	for(int i = 0; i < mult[0]; i++) {
		for(int j = 0; j < N; j++) v[j] = A[j] + i % mult[j] / mult[j + 1];
		//for(int j = 0; j < N; j++) printf("%d ", v[j]);
		//printf("\n");
		int res;
		for(int j = 0; j < P; j++) {
			int bor = 0;
			for(int k = sum[j]; k < sum[j + 1]; k++) bor |= v[k];
			if(j == 0) res = bor;
			else res &= bor;
		}
		ans = max(ans, res);
		//printf("*\n");
	}

	cout << ans;
	return 0;
}

Compilation message

bitwise.cpp: In function 'int main()':
bitwise.cpp:29:7: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int res;
       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 66 ms 380 KB Output is correct
6 Correct 36 ms 508 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Execution timed out 1065 ms 256 KB Time limit exceeded
9 Execution timed out 1077 ms 256 KB Time limit exceeded
10 Execution timed out 1077 ms 256 KB Time limit exceeded
11 Incorrect 2 ms 256 KB Output isn't correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Incorrect 2 ms 256 KB Output isn't correct
15 Incorrect 2 ms 256 KB Output isn't correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Incorrect 2 ms 376 KB Output isn't correct
18 Incorrect 2 ms 376 KB Output isn't correct
19 Incorrect 2 ms 376 KB Output isn't correct
20 Incorrect 2 ms 376 KB Output isn't correct