답안 #123097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123097 2019-06-30T08:36:52 Z tjd229 Broken Device (JOI17_broken_device) C++11
100 / 100
45 ms 3064 KB
#include "Annalib.h"
void Anna(int N, long long X, int K, int P[]) {

	int mem[150];
	int b[70] = { 0 };
	for (int i = 0; i < N; ++i) mem[i] = 1;
	for (int i = 0; i < K; ++i) mem[P[i]] = 0;
	for (int i = 0; X; ++i,X>>=1) 
		b[i] = X & 1;
	int pos = 0;
	for (int i = 0; i < N; i += 3) {
		int s = mem[i] + mem[i + 1] + mem[i + 2];
		int mask = (mem[i] << 2) + mem[i + 1] + mem[i + 1] + mem[i + 2];
		int w = 0;
		if (pos >= 60) {
			mem[i] = mem[i + 1] = mem[i + 2] = 0;
			continue;
		}
		if (mask == 7 && b[pos] + b[pos + 1]==2) {
			w = 7;
			pos += 2;
		}
		else if ((mask & 2) == 2 && b[pos] + b[pos + 1] == 0) {
			w = 2;
			pos += 2;
		}
		
		else if ((mask & 5)==5 && b[pos]==1&& b[pos + 1] == 0) {
			w = 5;
			pos += 2;
		}
		else if ((mask & 3)==3 && b[pos] == 0 && b[pos + 1] == 1) {
			w = 3;
			pos += 2;
		}
		else if ((mask & 6)==6 && b[pos]) {
			w = 6;
			++pos;
		}
		else if ((mask & 1) &&b[pos]) {
			w = 1;
			++pos;
		}
		else if ((mask & 4) == 4 && b[pos] == 0 ) {
			w = 4;
			++pos;
		}
		mem[i] = (w & 4) >> 2;
		mem[i + 1] = (w&2) >> 1;
		mem[i + 2] = w & 1;

	}
	for (int i = 0; i < N; ++i) Set(i, mem[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; 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;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:12:7: warning: unused variable 's' [-Wunused-variable]
   int s = mem[i] + mem[i + 1] + mem[i + 2];
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 3056 KB Output is correct - L* = 40
2 Correct 39 ms 2896 KB Output is correct - L* = 40
3 Correct 39 ms 2800 KB Output is correct - L* = 40
4 Correct 45 ms 2800 KB Output is correct - L* = 40
5 Correct 40 ms 2800 KB Output is correct - L* = 40
6 Correct 39 ms 2800 KB Output is correct - L* = 40
7 Correct 40 ms 2968 KB Output is correct - L* = 40
8 Correct 40 ms 2800 KB Output is correct - L* = 40
9 Correct 39 ms 3056 KB Output is correct - L* = 40
10 Correct 39 ms 2800 KB Output is correct - L* = 40
11 Correct 40 ms 3056 KB Output is correct - L* = 40
12 Correct 39 ms 3032 KB Output is correct - L* = 40
13 Correct 39 ms 3064 KB Output is correct - L* = 40
14 Correct 39 ms 3056 KB Output is correct - L* = 40
15 Correct 39 ms 2800 KB Output is correct - L* = 40
16 Correct 39 ms 3032 KB Output is correct - L* = 40
17 Correct 39 ms 3056 KB Output is correct - L* = 40
18 Correct 39 ms 2800 KB Output is correct - L* = 40
19 Correct 40 ms 3056 KB Output is correct - L* = 40
20 Correct 39 ms 2800 KB Output is correct - L* = 40
21 Correct 39 ms 2800 KB Output is correct - L* = 40
22 Correct 40 ms 2848 KB Output is correct - L* = 40
23 Correct 39 ms 3064 KB Output is correct - L* = 40
24 Correct 39 ms 3056 KB Output is correct - L* = 40
25 Correct 39 ms 3000 KB Output is correct - L* = 40
26 Correct 39 ms 2800 KB Output is correct - L* = 40
27 Correct 39 ms 3056 KB Output is correct - L* = 40
28 Correct 39 ms 2800 KB Output is correct - L* = 40
29 Correct 39 ms 2872 KB Output is correct - L* = 40
30 Correct 39 ms 2800 KB Output is correct - L* = 40
31 Correct 39 ms 3056 KB Output is correct - L* = 40
32 Correct 39 ms 2976 KB Output is correct - L* = 40
33 Correct 39 ms 2800 KB Output is correct - L* = 40
34 Correct 40 ms 2808 KB Output is correct - L* = 40
35 Correct 39 ms 2800 KB Output is correct - L* = 40
36 Correct 40 ms 2800 KB Output is correct - L* = 40
37 Correct 39 ms 2800 KB Output is correct - L* = 40
38 Correct 39 ms 2808 KB Output is correct - L* = 40
39 Correct 39 ms 3056 KB Output is correct - L* = 40
40 Correct 39 ms 3056 KB Output is correct - L* = 40