답안 #61224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61224 2018-07-25T11:38:43 Z gs14004 Broken Device (JOI17_broken_device) C++17
100 / 100
86 ms 3944 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

int seq[222];
int chk[222];

void Embed(int pos, int val){
	Set(pos, val >> 2);
	Set(pos + 1, (val >> 1) & 1);
	Set(pos + 2, val & 1);
}

void Anna( int N, long long X, int K, int P[] ){
	for(int i=0; i<60; i++){
		seq[i] = (X >> i) & 1;
	}
	for(int i=0; i<150; i++) chk[i] = 1;
	for(int i=0; i<K; i++){
		chk[P[i]] = 0;
	}
	int ptr = 0;
	for(int i=0; i<150; i+=3){
		if(chk[i] + chk[i+1] + chk[i+2] <= 1){
			Embed(i, 0);
		}
		else if(chk[i] + chk[i+1] + chk[i+2] == 3){
			if(seq[ptr] == 0 && seq[ptr+1] == 0){
				Embed(i, 4);
			}
			else if(seq[ptr] == 0 && seq[ptr+1] == 1){
				Embed(i, 6);
			}
			else if(seq[ptr] == 1 & seq[ptr+1] == 0){
				Embed(i, 3);
			}
			else{
				Embed(i, 7);
			}
			ptr += 2;
		}
		else{
			if(seq[ptr] == 0){
				if(chk[i+2] == 1){
					Embed(i, 1);
					ptr++;
				}
				else{
					if(seq[ptr+1] == 0){
						Embed(i, 4);
					}
					else{
						Embed(i, 6);
					}
					ptr += 2;
				}
			}
			else{
				if(chk[i+1] == 0) Embed(i, 5);
				else Embed(i, 2);
				ptr++;
			}
		}
	}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

long long Bruno( int N, int A[] ){
	vector<int> ans;
	for(int i=0; i<150; i+=3){
		int val = (A[i] << 2) | (A[i+1] << 1) | (A[i+2]);
		if(val == 1){
			ans.push_back(0);
		}
		if(val == 2){
			ans.push_back(1);
		}
		if(val == 3){
			ans.push_back(1);
			ans.push_back(0);
		}
		if(val == 4){
			ans.push_back(0);
			ans.push_back(0);
		}
		if(val == 5){
			ans.push_back(1);
		}
		if(val == 6){
			ans.push_back(0);
			ans.push_back(1);
		}
		if(val == 7){
			ans.push_back(1);
			ans.push_back(1);
		}
	}
	long long dap = 0;
	assert(ans.size() >= 60);
	for(int i=0; i<60; i++){
		if(ans[i]) dap |= (1ll << i);
	}
	return dap;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:34:21: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    else if(seq[ptr] == 1 & seq[ptr+1] == 0){
            ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 3056 KB Output is correct - L* = 40
2 Correct 68 ms 3264 KB Output is correct - L* = 40
3 Correct 63 ms 3416 KB Output is correct - L* = 40
4 Correct 47 ms 3416 KB Output is correct - L* = 40
5 Correct 56 ms 3416 KB Output is correct - L* = 40
6 Correct 67 ms 3600 KB Output is correct - L* = 40
7 Correct 54 ms 3600 KB Output is correct - L* = 40
8 Correct 49 ms 3696 KB Output is correct - L* = 40
9 Correct 71 ms 3712 KB Output is correct - L* = 40
10 Correct 60 ms 3744 KB Output is correct - L* = 40
11 Correct 49 ms 3744 KB Output is correct - L* = 40
12 Correct 49 ms 3744 KB Output is correct - L* = 40
13 Correct 48 ms 3744 KB Output is correct - L* = 40
14 Correct 48 ms 3744 KB Output is correct - L* = 40
15 Correct 48 ms 3744 KB Output is correct - L* = 40
16 Correct 47 ms 3744 KB Output is correct - L* = 40
17 Correct 52 ms 3856 KB Output is correct - L* = 40
18 Correct 49 ms 3856 KB Output is correct - L* = 40
19 Correct 52 ms 3856 KB Output is correct - L* = 40
20 Correct 77 ms 3856 KB Output is correct - L* = 40
21 Correct 66 ms 3856 KB Output is correct - L* = 40
22 Correct 86 ms 3856 KB Output is correct - L* = 40
23 Correct 60 ms 3856 KB Output is correct - L* = 40
24 Correct 70 ms 3856 KB Output is correct - L* = 40
25 Correct 52 ms 3856 KB Output is correct - L* = 40
26 Correct 54 ms 3856 KB Output is correct - L* = 40
27 Correct 55 ms 3856 KB Output is correct - L* = 40
28 Correct 61 ms 3856 KB Output is correct - L* = 40
29 Correct 65 ms 3856 KB Output is correct - L* = 40
30 Correct 59 ms 3856 KB Output is correct - L* = 40
31 Correct 66 ms 3856 KB Output is correct - L* = 40
32 Correct 53 ms 3856 KB Output is correct - L* = 40
33 Correct 64 ms 3856 KB Output is correct - L* = 40
34 Correct 57 ms 3944 KB Output is correct - L* = 40
35 Correct 76 ms 3944 KB Output is correct - L* = 40
36 Correct 56 ms 3944 KB Output is correct - L* = 40
37 Correct 55 ms 3944 KB Output is correct - L* = 40
38 Correct 58 ms 3944 KB Output is correct - L* = 40
39 Correct 74 ms 3944 KB Output is correct - L* = 40
40 Correct 67 ms 3944 KB Output is correct - L* = 40