답안 #71619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71619 2018-08-25T08:47:10 Z Bruteforceman Broken Device (JOI17_broken_device) C++11
0 / 100
1136 ms 14984 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) {
        ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 944 ms 5008 KB Program terminated incorrectly, or you printed something to stdout
2 Incorrect 968 ms 5880 KB Program terminated incorrectly, or you printed something to stdout
3 Incorrect 1069 ms 5880 KB Program terminated incorrectly, or you printed something to stdout
4 Incorrect 981 ms 6368 KB Program terminated incorrectly, or you printed something to stdout
5 Incorrect 1051 ms 6368 KB Program terminated incorrectly, or you printed something to stdout
6 Incorrect 942 ms 6680 KB Program terminated incorrectly, or you printed something to stdout
7 Incorrect 1075 ms 6800 KB Program terminated incorrectly, or you printed something to stdout
8 Incorrect 1040 ms 7272 KB Program terminated incorrectly, or you printed something to stdout
9 Incorrect 961 ms 7280 KB Program terminated incorrectly, or you printed something to stdout
10 Incorrect 961 ms 7688 KB Program terminated incorrectly, or you printed something to stdout
11 Incorrect 960 ms 7760 KB Program terminated incorrectly, or you printed something to stdout
12 Incorrect 1050 ms 8152 KB Program terminated incorrectly, or you printed something to stdout
13 Incorrect 950 ms 8200 KB Program terminated incorrectly, or you printed something to stdout
14 Incorrect 989 ms 8784 KB Program terminated incorrectly, or you printed something to stdout
15 Incorrect 938 ms 9208 KB Program terminated incorrectly, or you printed something to stdout
16 Incorrect 931 ms 9208 KB Program terminated incorrectly, or you printed something to stdout
17 Incorrect 998 ms 9344 KB Program terminated incorrectly, or you printed something to stdout
18 Incorrect 1063 ms 9344 KB Program terminated incorrectly, or you printed something to stdout
19 Incorrect 1019 ms 9656 KB Program terminated incorrectly, or you printed something to stdout
20 Incorrect 925 ms 9720 KB Program terminated incorrectly, or you printed something to stdout
21 Incorrect 959 ms 10128 KB Program terminated incorrectly, or you printed something to stdout
22 Incorrect 999 ms 10400 KB Program terminated incorrectly, or you printed something to stdout
23 Incorrect 1073 ms 10792 KB Program terminated incorrectly, or you printed something to stdout
24 Incorrect 1002 ms 11024 KB Program terminated incorrectly, or you printed something to stdout
25 Incorrect 996 ms 11096 KB Program terminated incorrectly, or you printed something to stdout
26 Incorrect 947 ms 11344 KB Program terminated incorrectly, or you printed something to stdout
27 Incorrect 958 ms 11848 KB Program terminated incorrectly, or you printed something to stdout
28 Incorrect 991 ms 11952 KB Program terminated incorrectly, or you printed something to stdout
29 Incorrect 929 ms 12264 KB Program terminated incorrectly, or you printed something to stdout
30 Incorrect 1018 ms 12912 KB Program terminated incorrectly, or you printed something to stdout
31 Incorrect 1136 ms 12912 KB Program terminated incorrectly, or you printed something to stdout
32 Incorrect 1022 ms 13128 KB Program terminated incorrectly, or you printed something to stdout
33 Incorrect 1016 ms 13128 KB Program terminated incorrectly, or you printed something to stdout
34 Incorrect 1047 ms 13336 KB Program terminated incorrectly, or you printed something to stdout
35 Incorrect 1057 ms 13520 KB Program terminated incorrectly, or you printed something to stdout
36 Incorrect 985 ms 13832 KB Program terminated incorrectly, or you printed something to stdout
37 Incorrect 1039 ms 14072 KB Program terminated incorrectly, or you printed something to stdout
38 Incorrect 1006 ms 14784 KB Program terminated incorrectly, or you printed something to stdout
39 Incorrect 969 ms 14784 KB Program terminated incorrectly, or you printed something to stdout
40 Incorrect 1000 ms 14984 KB Program terminated incorrectly, or you printed something to stdout