답안 #293166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
293166 2020-09-07T17:20:09 Z Berted Broken Device (JOI17_broken_device) C++14
100 / 100
51 ms 3568 KB
#include "Annalib.h"
#include <iostream>

using namespace std;

/*
	Translation Table :
	000 -> No info.
	001 -> 0
	010 -> 1
	011 -> 01
	100 -> 00
	101 -> 1
	110 -> 10
	111 -> 11

	Main idea :
	- Split into blocks of size 3
	- If more than one bit is broke, you can do nothing
	- If one bit is broke, send at least 1 bits of information
	- If none is broke, send at least 2 bits of information
*/

int s[151];

void Anna(int N, long long X, int K, int P[])
{
	for (int i = 0; i < N; i++) {s[i] = 0;}
	for (int i = 0; i < K; i++) {s[P[i]] = 1;}
	for (int i = 0; i < N; i += 3)
	{
		int cnt = s[i] + s[i + 1] + s[i + 2];
		if (cnt > 1) {Set(i, 0); Set(i + 1, 0); Set(i + 2, 0);}
		else if (s[i])
		{
			Set(i, 0);
			if (X & 1) {Set(i + 1, 1); Set(i + 2, 0);}
			else {Set(i + 1, 0); Set(i + 2, 1);} 
			X >>= 1;
		}
		else if (s[i + 1])
		{
			Set(i + 1, 0);
			if (X & 1) {Set(i, 1); Set(i + 2, 1);}
			else {Set(i, 0); Set(i + 2, 1);}
			X >>= 1;
		}
		else if (s[i + 2])
		{
			Set(i + 2, 0);
			if (X & 1) {Set(i, 0); Set(i + 1, 1); X >>= 1;}
			else if (X & 3) {Set(i, 1); Set(i + 1, 1); X >>= 2;}
			else {Set(i, 1); Set(i + 1, 0); X >>= 2;}
		}
		else
		{
			if ((X & 3) == 0) {Set(i, 1); Set(i + 1, 0); Set(i + 2, 0);}
			else if ((X & 3) == 1) {Set(i, 0); Set(i + 1, 1); Set(i + 2, 1);}
			else if ((X & 3) == 2) {Set(i, 1); Set(i + 1, 1); Set(i + 2, 0);}
			else {Set(i, 1); Set(i + 1, 1); Set(i + 2, 1);}
			X >>= 2;
		}
	}
}
#include "Brunolib.h"

long long Bruno(int N, int A[])
{
	long long res = 0, k = 1;
	for (int i = 0; i < N; i += 3)
	{
		int val = A[i] << 2 | A[i + 1] << 1 | A[i + 2];
		if (val == 1) {k <<= 1;}
		else if (val == 2) {res |= 1 * k; k <<= 1;}
		else if (val == 3) {res |= 1 * k; k <<= 2;}
		else if (val == 4) {k <<= 2;}
		else if (val == 5) {res |= 1 * k; k <<= 1;}
		else if (val == 6) {res |= 2 * k; k <<= 2;}
		else if (val == 7) {res |= 3 * k; k <<= 2;}
		//cout << res << "\n";
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 3312 KB Output is correct - L* = 40
2 Correct 44 ms 3328 KB Output is correct - L* = 40
3 Correct 41 ms 3328 KB Output is correct - L* = 40
4 Correct 41 ms 3312 KB Output is correct - L* = 40
5 Correct 43 ms 3312 KB Output is correct - L* = 40
6 Correct 43 ms 3312 KB Output is correct - L* = 40
7 Correct 43 ms 3312 KB Output is correct - L* = 40
8 Correct 41 ms 3328 KB Output is correct - L* = 40
9 Correct 41 ms 3568 KB Output is correct - L* = 40
10 Correct 41 ms 3328 KB Output is correct - L* = 40
11 Correct 41 ms 3328 KB Output is correct - L* = 40
12 Correct 41 ms 3328 KB Output is correct - L* = 40
13 Correct 41 ms 3328 KB Output is correct - L* = 40
14 Correct 43 ms 3312 KB Output is correct - L* = 40
15 Correct 44 ms 3312 KB Output is correct - L* = 40
16 Correct 43 ms 3328 KB Output is correct - L* = 40
17 Correct 41 ms 3328 KB Output is correct - L* = 40
18 Correct 51 ms 3328 KB Output is correct - L* = 40
19 Correct 42 ms 3328 KB Output is correct - L* = 40
20 Correct 41 ms 3328 KB Output is correct - L* = 40
21 Correct 44 ms 3312 KB Output is correct - L* = 40
22 Correct 43 ms 3328 KB Output is correct - L* = 40
23 Correct 42 ms 3328 KB Output is correct - L* = 40
24 Correct 42 ms 3328 KB Output is correct - L* = 40
25 Correct 43 ms 3328 KB Output is correct - L* = 40
26 Correct 45 ms 3568 KB Output is correct - L* = 40
27 Correct 43 ms 3312 KB Output is correct - L* = 40
28 Correct 43 ms 3176 KB Output is correct - L* = 40
29 Correct 45 ms 3328 KB Output is correct - L* = 40
30 Correct 43 ms 3312 KB Output is correct - L* = 40
31 Correct 43 ms 3312 KB Output is correct - L* = 40
32 Correct 41 ms 3312 KB Output is correct - L* = 40
33 Correct 42 ms 3312 KB Output is correct - L* = 40
34 Correct 43 ms 3328 KB Output is correct - L* = 40
35 Correct 43 ms 3312 KB Output is correct - L* = 40
36 Correct 44 ms 3312 KB Output is correct - L* = 40
37 Correct 45 ms 3312 KB Output is correct - L* = 40
38 Correct 45 ms 3568 KB Output is correct - L* = 40
39 Correct 44 ms 3312 KB Output is correct - L* = 40
40 Correct 41 ms 3328 KB Output is correct - L* = 40