답안 #125593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125593 2019-07-06T03:37:58 Z tjd229 Broken Device (JOI17_broken_device) C++14
100 / 100
51 ms 3064 KB
#include "Annalib.h"

void Anna(int N, long long X, int K, int P[]) {
	int A[150];
	for (int i = 0; i < N; ++i) A[i] = 1;
	for (int i = 0; i < K; ++i) A[P[i]] = 0;
	
	for (int i = 0; i < N ; i += 3) {
		int s = A[i] + A[i + 1] + A[i + 2];
		if (!s) continue;
		if (X & 1) {
			if ((X & 2) && s == 3) X >>= 2;//111
			else if ((X & 2) == 0 && (A[i + 2] & A[i])) X >>= 2, A[i + 1] = 0;//101
			else if (A[i + 2]) A[i] = A[i + 1] = 0, X >>= 1;//001 or 110
			else if (A[i + 1] & A[i]) A[i + 2] = 0, X >>= 1;
			else A[i] = A[i + 1] = A[i + 2] = 0;
		}
		else{
			if ((X & 2) && A[i+1] + A[i + 2] == 2) {//011[01]
				A[i] = 0;
				X >>= 2;
			}
			else if ((X & 2) == 0 && A[1+i]) {//010[00]
				A[i] = A[i + 2] = 0;
				X >>= 2;
			}
			else if (A[i]) {//100
				A[i+1] = A[i + 2] = 0;
				X >>= 1;
			}
			else A[i] = A[i + 1] = A[i + 2] = 0;
		}
		

	}
	for (int i = 0; i < N; ++i) Set(i, A[i]);
}
#include "Brunolib.h"
long long Bruno(int N, int A[]) {
	long long X = 0;
	int recon[70] = { 0 };
	int pos = 0;
	for (int i = 0; i < N && pos<60; i += 3) {
		int mask = (A[i] << 2) + A[i + 1] + A[i + 1] + A[i + 2];
		if (mask == 1 || mask == 6) recon[pos++] = 1;
		else if (mask == 2) pos += 2;
		else if (mask == 3) recon[++pos] = 1, ++pos;
		else if (mask == 4) ++pos;
		else if (mask == 5) recon[pos++] = 1, ++pos;
		else if (mask == 7)
			recon[pos] = recon[pos + 1] = 1, pos += 2;
	}
	//printf("%d\n",pos);
	pos = 60;
	while (pos--) {
		X <<= 1;
		X += recon[pos];
	}
	return X;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2800 KB Output is correct - L* = 40
2 Correct 40 ms 2800 KB Output is correct - L* = 40
3 Correct 39 ms 3064 KB Output is correct - L* = 40
4 Correct 39 ms 3056 KB Output is correct - L* = 40
5 Correct 39 ms 2800 KB Output is correct - L* = 40
6 Correct 39 ms 3056 KB Output is correct - L* = 40
7 Correct 39 ms 2888 KB Output is correct - L* = 40
8 Correct 39 ms 3056 KB Output is correct - L* = 40
9 Correct 39 ms 3056 KB Output is correct - L* = 40
10 Correct 40 ms 2896 KB Output is correct - L* = 40
11 Correct 40 ms 3056 KB Output is correct - L* = 40
12 Correct 39 ms 3056 KB Output is correct - L* = 40
13 Correct 51 ms 2832 KB Output is correct - L* = 40
14 Correct 44 ms 2800 KB Output is correct - L* = 40
15 Correct 44 ms 3056 KB Output is correct - L* = 40
16 Correct 39 ms 2800 KB Output is correct - L* = 40
17 Correct 39 ms 3056 KB Output is correct - L* = 40
18 Correct 39 ms 3048 KB Output is correct - L* = 40
19 Correct 39 ms 2800 KB Output is correct - L* = 40
20 Correct 39 ms 3056 KB Output is correct - L* = 40
21 Correct 39 ms 2800 KB Output is correct - L* = 40
22 Correct 39 ms 3056 KB Output is correct - L* = 40
23 Correct 41 ms 2888 KB Output is correct - L* = 40
24 Correct 39 ms 2800 KB Output is correct - L* = 40
25 Correct 39 ms 2880 KB Output is correct - L* = 40
26 Correct 39 ms 3056 KB Output is correct - L* = 40
27 Correct 39 ms 2800 KB Output is correct - L* = 40
28 Correct 39 ms 2800 KB Output is correct - L* = 40
29 Correct 39 ms 2800 KB Output is correct - L* = 40
30 Correct 39 ms 2800 KB Output is correct - L* = 40
31 Correct 39 ms 2800 KB Output is correct - L* = 40
32 Correct 39 ms 3056 KB Output is correct - L* = 40
33 Correct 39 ms 2800 KB Output is correct - L* = 40
34 Correct 39 ms 2800 KB Output is correct - L* = 40
35 Correct 39 ms 2992 KB Output is correct - L* = 40
36 Correct 39 ms 3056 KB Output is correct - L* = 40
37 Correct 40 ms 3000 KB Output is correct - L* = 40
38 Correct 39 ms 3056 KB Output is correct - L* = 40
39 Correct 39 ms 2800 KB Output is correct - L* = 40
40 Correct 40 ms 3056 KB Output is correct - L* = 40