Submission #71620

# Submission time Handle Problem Language Result Execution time Memory
71620 2018-08-25T08:49:24 Z Bruteforceman Broken Device (JOI17_broken_device) C++11
100 / 100
76 ms 3744 KB
#include "Annalib.h"
#include "bits/stdc++.h"
using namespace std;

// 100 = 0
// 011 = 0
// 010 = 1
// 101 = 1

// 111
// 101
// 110
// 000 

void Anna( int N, long long X, int K, int P[] ){
	int broke[N];
	for(int i = 0; i < N; i++) {
		broke[i] = 0;
	}
	for(int i = 0; i < K; i++) {
		broke[P[i]] = 1;
	}
	string s = "";
	int bit = 0;

	for(int i = 0; i < N; i += 3) {
		if(bit > 62) break;
		int cnt = broke[i] + broke[i+1] + broke[i+2];
		if(cnt == 1) {
			if(broke[i]) {
				if((X >> bit) & 1) {
					s += "010";
				} else {
					s += "001";
				} 
				++bit;
			} else if (broke[i+1]) {
				int p = (X >> bit) & 1;
				++bit;
				int q = (X >> bit) & 1;
				++bit;
				if(p == 0) {
					s += "001";
					--bit;
				}
				if(p == 1 && q == 0) s += "100";
				if(p == 1 && q == 1) s += "101";
			} else {
				if((X >> bit) & 1) {
					s += "010";
				} else {
					s += "110";
				}
				++bit;
			}
		} else if (cnt == 0) {
			int p = (X >> bit) & 1;
			++bit;
			int q = (X >> bit) & 1;
			++bit;
			if(p == 0 && q == 0) {
				s += "011";
			}	
			if(p == 0 && q == 1) {
				s += "111";
			}
			if(p == 1 && q == 0) {
				s += "100";
			} 
			if(p == 1 && q == 1) {
				s += "101";
			}
		} else {
			s += "000";
		}
	}
	while(s.size() < N) {
		s += "0";
	}
	// cerr << "bits covered: " << bit << endl; 
	for(int i = 0; i < N; i++) {
		// cerr << i << ' ' << s[i] << endl;
		Set(i, s[i] - '0');
	} 
}
#include "Brunolib.h"
#include "bits/stdc++.h"
using namespace std;
long long Bruno( int N, int A[] ){
	int bit = 0;
	long long ans = 0;
	for(int i = 0; i < N; i += 3) {
		if(bit > 61) break;
		string s = "";
		s += char (A[i] + '0');
		s += char (A[i+1] + '0');
		s += char (A[i+2] + '0');

		if(s == "010") {
			ans |= 1LL << bit;
			++bit;
		}
		if(s == "001" || s == "110") {
			++bit;
		} 
		if(s == "011") {
			bit += 2;
		}
		if(s == "111") {
			++bit;
			ans |= 1LL << bit;
			++bit;
		}
		if(s == "100") {
			ans |= 1LL << bit;
			++bit;
			++bit;
		}
		if(s == "101") {
			ans |= 1LL << bit;
			++bit;
			ans |= 1LL << bit;
			++bit;
		}
	}
	// cerr << "found " << ans << endl;
	return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:77:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(s.size() < N) {
        ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 61 ms 3056 KB Output is correct - L* = 40
2 Correct 68 ms 3232 KB Output is correct - L* = 40
3 Correct 57 ms 3592 KB Output is correct - L* = 40
4 Correct 61 ms 3592 KB Output is correct - L* = 40
5 Correct 51 ms 3592 KB Output is correct - L* = 40
6 Correct 61 ms 3592 KB Output is correct - L* = 40
7 Correct 64 ms 3688 KB Output is correct - L* = 40
8 Correct 68 ms 3688 KB Output is correct - L* = 40
9 Correct 56 ms 3688 KB Output is correct - L* = 40
10 Correct 72 ms 3712 KB Output is correct - L* = 40
11 Correct 54 ms 3712 KB Output is correct - L* = 40
12 Correct 68 ms 3712 KB Output is correct - L* = 40
13 Correct 60 ms 3712 KB Output is correct - L* = 40
14 Correct 48 ms 3712 KB Output is correct - L* = 40
15 Correct 53 ms 3712 KB Output is correct - L* = 40
16 Correct 51 ms 3712 KB Output is correct - L* = 40
17 Correct 53 ms 3712 KB Output is correct - L* = 40
18 Correct 54 ms 3712 KB Output is correct - L* = 40
19 Correct 74 ms 3712 KB Output is correct - L* = 40
20 Correct 55 ms 3712 KB Output is correct - L* = 40
21 Correct 59 ms 3712 KB Output is correct - L* = 40
22 Correct 62 ms 3712 KB Output is correct - L* = 40
23 Correct 59 ms 3712 KB Output is correct - L* = 40
24 Correct 52 ms 3712 KB Output is correct - L* = 40
25 Correct 60 ms 3744 KB Output is correct - L* = 40
26 Correct 71 ms 3744 KB Output is correct - L* = 40
27 Correct 54 ms 3744 KB Output is correct - L* = 40
28 Correct 51 ms 3744 KB Output is correct - L* = 40
29 Correct 53 ms 3744 KB Output is correct - L* = 40
30 Correct 51 ms 3744 KB Output is correct - L* = 40
31 Correct 55 ms 3744 KB Output is correct - L* = 40
32 Correct 76 ms 3744 KB Output is correct - L* = 40
33 Correct 74 ms 3744 KB Output is correct - L* = 40
34 Correct 56 ms 3744 KB Output is correct - L* = 40
35 Correct 61 ms 3744 KB Output is correct - L* = 40
36 Correct 61 ms 3744 KB Output is correct - L* = 40
37 Correct 65 ms 3744 KB Output is correct - L* = 40
38 Correct 64 ms 3744 KB Output is correct - L* = 40
39 Correct 56 ms 3744 KB Output is correct - L* = 40
40 Correct 60 ms 3744 KB Output is correct - L* = 40