Submission #137520

# Submission time Handle Problem Language Result Execution time Memory
137520 2019-07-28T06:03:18 Z 송준혁(#3282) Bitwise (BOI06_bitwise) C++14
35 / 100
2 ms 380 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, P, ans;
int S[110], A[110], B[110];
bool O[110];

int main(){
	scanf("%d %d", &N, &P);
	for (int i=1; i<=P; i++) {
		scanf("%d", &S[i]);
		S[i] += S[i-1];
	}
	for (int i=1; i<=N; i++) scanf("%d %d", &A[i], &B[i]);
	for (int i=30; i>=0; i--){
		bool tf=true, chk=false;
		memset(O, false, sizeof O);
		for (int j=1,k=1; j<=N; j++){
			if (A[j] >= (1 << i)) O[k] = true, chk = true;
			else if (B[j] >= (1 << i)) chk = true;
			if (S[k] == j){
				if (!chk) tf = false;
				chk = false, k++;
			}
		}

		if (tf){
			ans |= 1 << i;
			for (int j=1,k=1; j<=N; j++){
				if (A[j] >= (1 << i)) A[j] -= 1 << i, B[j] -= 1 << i; 
				else if (B[j] >= (1 << i) && !O[k]){
					O[k] = true;
					A[j] = 0, B[j] -= 1 << i;
				}
				if (S[k] == j){
					if (!chk) tf = false;
					chk = false, k++;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

bitwise.cpp: In function 'int main()':
bitwise.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &P);
  ~~~~~^~~~~~~~~~~~~~~~~
bitwise.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &S[i]);
   ~~~~~^~~~~~~~~~~~~
bitwise.cpp:16:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1; i<=N; i++) scanf("%d %d", &A[i], &B[i]);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Incorrect 2 ms 256 KB Output isn't correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Correct 2 ms 256 KB Output is correct
11 Incorrect 2 ms 256 KB Output isn't correct
12 Correct 2 ms 256 KB Output is correct
13 Incorrect 2 ms 256 KB Output isn't correct
14 Incorrect 2 ms 256 KB Output isn't correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Incorrect 2 ms 256 KB Output isn't correct
18 Incorrect 2 ms 252 KB Output isn't correct
19 Incorrect 1 ms 376 KB Output isn't correct
20 Incorrect 2 ms 256 KB Output isn't correct