답안 #123077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123077 2019-06-30T07:37:24 Z tjd229 Broken Device (JOI17_broken_device) C++14
51 / 100
46 ms 3144 KB
#include "Annalib.h"
#include <stdio.h>
void Anna(int N, long long X, int K, int P[]) {
	int mem[150];
	int b[60] = { 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];
		if (s == 0) continue;
		//pos chk
		if (pos >= 60) {
			mem[i] = mem[i + 1] = mem[i + 2] = 0;
			continue;
		}
		else if (pos == 59) s = 1;
		if (s == 3) {
			if (b[pos] + b[pos + 1] == 2) mem[i] = mem[i + 1] = mem[i + 2] = 1;
			else if (b[pos] + b[pos + 1] == 0) {
				mem[i] = mem[i + 2] = 1;
				mem[i + 1] = 0;
			}
			else {
				mem[i] = mem[i + 2] = 0;
				mem[i + 1] = 1;
				mem[b[pos] ? i : i + 2] = 1;
			}
			pos += 2;
			continue;
		}
		if (s == 2) {
			if (mask == 3) {
				if (b[pos] == 0 && b[pos+1] == 1) {
					mem[i] = 0;
					mem[i + 1] = mem[i + 2] = 1;
					pos += 2;
				}
				else s = 1;
			}
			else if (mask == 6) {
				if (b[pos] == 1 && b[pos+1] == 0) {
					mem[i] = mem[i + 1] = 1;
					mem[i + 2] = 0;
					pos += 2;
				}
				else s = 1;
			}
			else {
				if (b[pos] + b[pos + 1] == 0) {
					mem[i] = mem[i + 2] = 1;
					mem[i + 1] = 0;
					pos += 2;
				}
				else s = 1;
			}
		}
		if (s == 1) {
			if (b[pos]) {
				if (mask & 6) {
					mem[i] = mem[i + 1] = mem[i + 2] = 0;
					mem[mask & 2 ? i + 1 : i] = 1;
					++pos;
					
				}
				else s = 0;
			}
			else {
				if (mask & 1) {
					mem[i] = mem[i + 1] = 0;
					mem[i + 2] = 1;
					++pos;
				}
				else s = 0;
			}
		}
		if (s == 0) mem[i] = mem[i + 1] = mem[i + 2] = 0;
	}
	for (int i = 0; i < N; ++i) Set(i, mem[i]);
	/*if (pos < 60) printf("!%d\n",pos);
	
	for (int i = 0; i < N; ++i) printf("%d ",i==P[0]? 2: mem[i]);
	puts("");*/
}
#include "Brunolib.h"
#include <stdio.h>
long long Bruno( int N, int A[] ){
	long long X = 0;
	int recon[60] = { 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) ++pos;
		else if (mask == 2 || mask == 4) recon[pos++] = 1;
		else if (mask == 3)//01
			recon[++pos] = 1, ++pos;
		else if (mask == 5) pos += 2;//00
		else if (mask == 6) recon[pos++] = 1, ++pos;
		else if (mask == 7)
			recon[pos] = recon[pos + 1] = 1, pos += 2;		
	}
	//printf("%d\n",pos);
	while (pos--) {
		X <<= 1;
		X += recon[pos];
	}
	//for (int i = 0; i <60; ++i) printf("%d ",recon[i]);
	//for (int i = 0; i < N; ++i) printf("%d ",  A[i]);
	//puts(" ");
	return X;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 40 ms 3056 KB Output is partially correct - L* = 24
2 Partially correct 39 ms 2800 KB Output is partially correct - L* = 22
3 Partially correct 39 ms 3104 KB Output is partially correct - L* = 21
4 Partially correct 39 ms 3000 KB Output is partially correct - L* = 23
5 Partially correct 39 ms 3056 KB Output is partially correct - L* = 20
6 Partially correct 40 ms 2800 KB Output is partially correct - L* = 24
7 Partially correct 39 ms 2800 KB Output is partially correct - L* = 23
8 Partially correct 40 ms 2800 KB Output is partially correct - L* = 20
9 Partially correct 39 ms 3064 KB Output is partially correct - L* = 20
10 Partially correct 39 ms 3056 KB Output is partially correct - L* = 25
11 Partially correct 39 ms 3056 KB Output is partially correct - L* = 22
12 Partially correct 39 ms 3056 KB Output is partially correct - L* = 24
13 Partially correct 39 ms 2800 KB Output is partially correct - L* = 20
14 Partially correct 39 ms 3056 KB Output is partially correct - L* = 24
15 Partially correct 39 ms 3056 KB Output is partially correct - L* = 21
16 Partially correct 40 ms 3056 KB Output is partially correct - L* = 23
17 Partially correct 41 ms 3056 KB Output is partially correct - L* = 21
18 Partially correct 39 ms 3056 KB Output is partially correct - L* = 25
19 Partially correct 40 ms 3056 KB Output is partially correct - L* = 24
20 Partially correct 39 ms 2800 KB Output is partially correct - L* = 21
21 Partially correct 40 ms 2800 KB Output is partially correct - L* = 20
22 Partially correct 39 ms 3056 KB Output is partially correct - L* = 20
23 Partially correct 40 ms 3056 KB Output is partially correct - L* = 20
24 Partially correct 41 ms 2864 KB Output is partially correct - L* = 22
25 Partially correct 43 ms 2800 KB Output is partially correct - L* = 21
26 Partially correct 39 ms 3144 KB Output is partially correct - L* = 25
27 Partially correct 43 ms 3056 KB Output is partially correct - L* = 22
28 Partially correct 40 ms 2800 KB Output is partially correct - L* = 22
29 Partially correct 46 ms 2800 KB Output is partially correct - L* = 23
30 Partially correct 41 ms 3056 KB Output is partially correct - L* = 23
31 Partially correct 39 ms 3056 KB Output is partially correct - L* = 22
32 Partially correct 41 ms 2800 KB Output is partially correct - L* = 23
33 Partially correct 40 ms 3056 KB Output is partially correct - L* = 22
34 Partially correct 39 ms 2800 KB Output is partially correct - L* = 27
35 Partially correct 39 ms 2800 KB Output is partially correct - L* = 20
36 Partially correct 40 ms 3056 KB Output is partially correct - L* = 22
37 Partially correct 40 ms 3056 KB Output is partially correct - L* = 20
38 Partially correct 39 ms 2800 KB Output is partially correct - L* = 22
39 Partially correct 39 ms 2800 KB Output is partially correct - L* = 21
40 Partially correct 44 ms 3000 KB Output is partially correct - L* = 22