답안 #23152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
23152 2017-05-03T17:03:56 Z kdh9949 Broken Device (JOI17_broken_device) C++14
100 / 100
46 ms 2836 KB
#include "Annalib.h"

void send(int x, int y){
	for(int t = 0; t < 3; t++, y /= 2) Set(x + 2 - t, y & 1);
}

void Anna(int N, long long X, int K, int P[]){
	int c[150] = {};
	for(int i = 0; i < K; i++) c[P[i]] = 1;
	int x[65] = {}, cnt = 0;
	for(int i = 0; i < 60; i++) x[i] = !!(X & (1LL << i));
	auto b = [](const int &x){ return __builtin_popcount(x); };
	for(int i = 0; i < 150; i += 3){
		int q = c[i] * 4 + c[i + 1] * 2 + c[i + 2];
		if(b(q) == 0){
            if(x[cnt]) send(i, 3 + 4 * x[cnt + 1]);
			else send(i, 4 + x[cnt + 1]);
			cnt += 2;
		}
		else if(b(q) == 1){
            if(q == 2){
				if(x[cnt]){
					send(i, 1);
					cnt++;
				}
                else{
					if(x[cnt + 1]) send(i, 5);
					else send(i, 4);
					cnt += 2;
                }
            }
            else{
				if(x[cnt]) send(i, q == 1 ? 6 : 1);
				else send(i, 2);
				cnt++;
            }
		}
		else send(i, 0);
		if(cnt >= 60) cnt = 60;
	}
}
#include "Brunolib.h"

static int v[8][2] = {{0, 0}, {1, 0}, {0, 0}, {1, 0}, {0, 0}, {0, 1}, {1, 0}, {1, 1}};
static int c[8] = {0, 1, 1, 2, 2, 2, 1, 2};

long long Bruno( int N, int A[] ){
    long long X = 0;
    int cnt = 0;
    for(int i = 0; i < 150; i += 3){
		int t = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
		for(int j = 0; j < c[t]; j++){
			X += (long long)v[t][j] << (cnt + j);
		}
		cnt += c[t];
    }
    return X;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 2836 KB Output is correct - L* = 40
2 Correct 25 ms 2836 KB Output is correct - L* = 40
3 Correct 45 ms 2836 KB Output is correct - L* = 40
4 Correct 39 ms 2836 KB Output is correct - L* = 40
5 Correct 46 ms 2836 KB Output is correct - L* = 40
6 Correct 32 ms 2836 KB Output is correct - L* = 40
7 Correct 41 ms 2836 KB Output is correct - L* = 40
8 Correct 39 ms 2836 KB Output is correct - L* = 40
9 Correct 41 ms 2836 KB Output is correct - L* = 40
10 Correct 28 ms 2836 KB Output is correct - L* = 40
11 Correct 38 ms 2836 KB Output is correct - L* = 40
12 Correct 28 ms 2836 KB Output is correct - L* = 40
13 Correct 38 ms 2836 KB Output is correct - L* = 40
14 Correct 35 ms 2836 KB Output is correct - L* = 40
15 Correct 35 ms 2836 KB Output is correct - L* = 40
16 Correct 35 ms 2836 KB Output is correct - L* = 40
17 Correct 35 ms 2836 KB Output is correct - L* = 40
18 Correct 35 ms 2836 KB Output is correct - L* = 40
19 Correct 32 ms 2836 KB Output is correct - L* = 40
20 Correct 32 ms 2836 KB Output is correct - L* = 40
21 Correct 32 ms 2836 KB Output is correct - L* = 40
22 Correct 35 ms 2836 KB Output is correct - L* = 40
23 Correct 32 ms 2836 KB Output is correct - L* = 40
24 Correct 38 ms 2836 KB Output is correct - L* = 40
25 Correct 36 ms 2836 KB Output is correct - L* = 40
26 Correct 28 ms 2836 KB Output is correct - L* = 40
27 Correct 35 ms 2836 KB Output is correct - L* = 40
28 Correct 35 ms 2836 KB Output is correct - L* = 40
29 Correct 41 ms 2836 KB Output is correct - L* = 40
30 Correct 28 ms 2836 KB Output is correct - L* = 40
31 Correct 35 ms 2836 KB Output is correct - L* = 40
32 Correct 35 ms 2836 KB Output is correct - L* = 40
33 Correct 28 ms 2836 KB Output is correct - L* = 40
34 Correct 35 ms 2836 KB Output is correct - L* = 40
35 Correct 35 ms 2836 KB Output is correct - L* = 40
36 Correct 35 ms 2836 KB Output is correct - L* = 40
37 Correct 35 ms 2836 KB Output is correct - L* = 40
38 Correct 35 ms 2836 KB Output is correct - L* = 40
39 Correct 28 ms 2836 KB Output is correct - L* = 40
40 Correct 39 ms 2836 KB Output is correct - L* = 40