Submission #290661

# Submission time Handle Problem Language Result Execution time Memory
290661 2020-09-04T09:41:01 Z maximath_1 Broken Device (JOI17_broken_device) C++11
100 / 100
52 ms 3824 KB
#include "Annalib.h"
#include <string.h>
using namespace std;

int broken[155], ret[155], bit[65];
void Anna(int N, long long X, int K, int P[]){
	for(int i = 0; i <= 60; i ++)
		if((X >> i) & 1ll) bit[i] = 1;
		else bit[i] = 0;

	memset(broken, 0, sizeof(broken));
	memset(ret, 0, sizeof(ret));
	for(int i = 0; i < K; i ++)
		broken[P[i]] = 1;

	int it = 0;
	for(int i = 0; i < N && it < 60; i += 3){
		int cnt = broken[i] + broken[i + 1] + broken[i + 2];
		if(cnt == 0){
			if(bit[it + 1] == 0){
				if(bit[it] == 0){
					ret[i] = 1; ret[i + 1] = ret[i + 2] = 0;
				}else{
					ret[i] = 0; ret[i + 1] = ret[i + 2] = 1;
				}
			}else{
				if(bit[it] == 0){
					ret[i] = ret[i + 1] = 1; ret[i + 2] = 0;
				}else{
					ret[i] = ret[i + 1] = ret[i + 2] = 1;
				}
			}
			it += 2;
		}else if(cnt == 1){
			if(broken[i]){
				if(bit[it] == 0){
					ret[i] = ret[i + 1] = 0; ret[i + 2] = 1;
				}else{
					ret[i] = ret[i + 2] = 0; ret[i + 1] = 1;
				}
				it ++;
			}else if(broken[i + 1]){
				if(bit[it] == 0){
					ret[i] = ret[i + 1] = 0; ret[i + 2] = 1;
				}else{
					ret[i] = ret[i + 2] = 1; ret[i + 1] = 0;
				}
				it ++;
			}else{
				if(bit[it] == 1){
					ret[i] = ret[i + 2] = 0; ret[i + 1] = 1;
					it ++;
				}else{
					if(bit[it + 1] == 0){
						ret[i] = 1; ret[i + 1] = ret[i + 2] = 0;
					}else{
						ret[i] = ret[i + 1] = 1; ret[i + 2] = 0;
					}
					it += 2;
				}
			}
		}
	}

	for(int i = 0; i < N; i ++)
		Set(i, ret[i]);
}
#include "Brunolib.h"
#include <iostream>
using namespace std;

int _bit[65];
long long Bruno(int N, int A[]){
	int it = 0;
	for(int i = 0; i < N && it < 60; i += 3){
		int gt = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
		if(gt == 0){
			//nothing	
		}else if(gt == 1){
			_bit[it] = 0; it ++;
		}else if(gt == 2){
			_bit[it] = 1; it ++;
		}else if(gt == 3){
			_bit[it] = 1; _bit[it + 1] = 0;
			it += 2;
		}else if(gt == 4){
			_bit[it] = _bit[it + 1] = 0;
			it += 2;
		}else if(gt == 5){
			_bit[it] = 1; it ++;
		}else if(gt == 6){
			_bit[it] = 0; _bit[it + 1] = 1;
			it += 2;
		}else if(gt == 7){
			_bit[it] = _bit[it + 1] = 1;
			it += 2;
		}
	}

	long long ans = 0ll;
	for(int i = 0; i <= 60; i ++)
		if(_bit[i]) ans += (1ll << i);

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3312 KB Output is correct - L* = 40
2 Correct 46 ms 3328 KB Output is correct - L* = 40
3 Correct 52 ms 3328 KB Output is correct - L* = 40
4 Correct 49 ms 3328 KB Output is correct - L* = 40
5 Correct 49 ms 3328 KB Output is correct - L* = 40
6 Correct 48 ms 3312 KB Output is correct - L* = 40
7 Correct 48 ms 3312 KB Output is correct - L* = 40
8 Correct 48 ms 3328 KB Output is correct - L* = 40
9 Correct 47 ms 3312 KB Output is correct - L* = 40
10 Correct 48 ms 3312 KB Output is correct - L* = 40
11 Correct 48 ms 3328 KB Output is correct - L* = 40
12 Correct 47 ms 3312 KB Output is correct - L* = 40
13 Correct 47 ms 3584 KB Output is correct - L* = 40
14 Correct 48 ms 3312 KB Output is correct - L* = 40
15 Correct 47 ms 3312 KB Output is correct - L* = 40
16 Correct 49 ms 3328 KB Output is correct - L* = 40
17 Correct 47 ms 3312 KB Output is correct - L* = 40
18 Correct 48 ms 3312 KB Output is correct - L* = 40
19 Correct 47 ms 3312 KB Output is correct - L* = 40
20 Correct 46 ms 3328 KB Output is correct - L* = 40
21 Correct 49 ms 3312 KB Output is correct - L* = 40
22 Correct 48 ms 3328 KB Output is correct - L* = 40
23 Correct 46 ms 3328 KB Output is correct - L* = 40
24 Correct 46 ms 3584 KB Output is correct - L* = 40
25 Correct 47 ms 3328 KB Output is correct - L* = 40
26 Correct 46 ms 3312 KB Output is correct - L* = 40
27 Correct 47 ms 3328 KB Output is correct - L* = 40
28 Correct 47 ms 3328 KB Output is correct - L* = 40
29 Correct 46 ms 3312 KB Output is correct - L* = 40
30 Correct 47 ms 3328 KB Output is correct - L* = 40
31 Correct 46 ms 3064 KB Output is correct - L* = 40
32 Correct 48 ms 3312 KB Output is correct - L* = 40
33 Correct 47 ms 3328 KB Output is correct - L* = 40
34 Correct 47 ms 3080 KB Output is correct - L* = 40
35 Correct 48 ms 3296 KB Output is correct - L* = 40
36 Correct 48 ms 3824 KB Output is correct - L* = 40
37 Correct 47 ms 3384 KB Output is correct - L* = 40
38 Correct 47 ms 3312 KB Output is correct - L* = 40
39 Correct 47 ms 3312 KB Output is correct - L* = 40
40 Correct 47 ms 3312 KB Output is correct - L* = 40