답안 #310976

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310976 2020-10-09T00:16:04 Z Lawliet Broken Device (JOI17_broken_device) C++17
100 / 100
56 ms 3328 KB
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200;

int ans[MAXN];

bool blocked[MAXN];

vector<int> bits;

void Anna(int N, long long X, int K, int P[])
{
	bits.clear();
	
	memset( ans , 0 , sizeof(ans) );
	memset( blocked , false , sizeof(blocked) );

	for(int i = 0 ; i < K ; i++)
		blocked[ P[i] ] = true;

	for(int i = 0 ; i < 150 ; i++)
		bits.push_back( X%2 ), X /= 2;

	for(int i = 0 ; i < N ; i += 3)
	{
		int optQtd = 0;

		//Ver se consigo enviar 1

		if( bits[0] == 1 && !blocked[i + 2] ) optQtd = 1;
		if( bits[0] == 0 && !blocked[i + 1] ) optQtd = 1;
		if( bits[0] == 0 && !blocked[i] && !blocked[i + 2] ) optQtd = 1; 

		//Ver se consigo enviar 2

		if( bits[0] == 0 && bits[1] == 0 && !blocked[i + 1] && !blocked[i + 2] ) optQtd = 2;
		if( bits[0] == 0 && bits[1] == 1 && !blocked[i] && !blocked[i + 1] && !blocked[i + 2] ) optQtd = 2;
		if( bits[0] == 1 && bits[1] == 0 && !blocked[i] ) optQtd = 2;
		if( bits[0] == 1 && bits[1] == 1 && !blocked[i] && !blocked[i + 1] ) optQtd = 2;

		if( optQtd == 0 ) continue;

		if( optQtd == 2 )
		{
			if( bits[0] == 0 && bits[1] == 0 ) ans[i + 1] = ans[i + 2] = 1; 
			if( bits[0] == 0 && bits[1] == 1 ) ans[i] = ans[i + 1] = ans[i + 2] = 1;
			if( bits[0] == 1 && bits[1] == 0 ) ans[i] = 1;
			if( bits[0] == 1 && bits[1] == 1 ) ans[i] = ans[i + 1] = 1;

			bits.erase( bits.begin() ); 
			bits.erase( bits.begin() );

			continue;
		}

		if( bits[0] == 1 ) ans[i + 2] = 1;
		else
		{
			if( !blocked[i + 1] ) ans[i + 1] = 1;
			else ans[i] = ans[i + 2] = 1;
		}

		bits.erase( bits.begin() );
	}

	for(int i = 0 ; i < N ; i++)
		Set( i , ans[i] );
}
#include "Brunolib.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;

long long Bruno(int N, int A[])
{
	lli ans = 0;

	for(int i = N - 3 ; i >= 0 ; i -= 3)
	{
		//if( A[i] == 0 && A[i + 1] == 0 && A[i + 2] == 0 ) 
		if( A[i] == 0 && A[i + 1] == 0 && A[i + 2] == 1 ) ans *= 2, ans += 1;
		if( A[i] == 0 && A[i + 1] == 1 && A[i + 2] == 0 ) ans *= 2, ans += 0;
		if( A[i] == 0 && A[i + 1] == 1 && A[i + 2] == 1 ) ans *= 4, ans += 0;
		if( A[i] == 1 && A[i + 1] == 0 && A[i + 2] == 0 ) ans *= 4, ans += 1;
		if( A[i] == 1 && A[i + 1] == 0 && A[i + 2] == 1 ) ans *= 2, ans += 0;
		if( A[i] == 1 && A[i + 1] == 1 && A[i + 2] == 0 ) ans *= 4, ans += 3;
		if( A[i] == 1 && A[i + 1] == 1 && A[i + 2] == 1 ) ans *= 4, ans += 2;
	}

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3072 KB Output is correct - L* = 40
2 Correct 48 ms 3072 KB Output is correct - L* = 40
3 Correct 48 ms 3056 KB Output is correct - L* = 40
4 Correct 48 ms 3072 KB Output is correct - L* = 40
5 Correct 48 ms 3072 KB Output is correct - L* = 40
6 Correct 48 ms 3072 KB Output is correct - L* = 40
7 Correct 48 ms 3072 KB Output is correct - L* = 40
8 Correct 48 ms 3064 KB Output is correct - L* = 40
9 Correct 49 ms 3072 KB Output is correct - L* = 40
10 Correct 48 ms 3056 KB Output is correct - L* = 40
11 Correct 48 ms 3328 KB Output is correct - L* = 40
12 Correct 48 ms 3064 KB Output is correct - L* = 40
13 Correct 51 ms 3072 KB Output is correct - L* = 40
14 Correct 48 ms 3072 KB Output is correct - L* = 40
15 Correct 48 ms 3072 KB Output is correct - L* = 40
16 Correct 48 ms 3064 KB Output is correct - L* = 40
17 Correct 48 ms 3328 KB Output is correct - L* = 40
18 Correct 48 ms 3056 KB Output is correct - L* = 40
19 Correct 48 ms 3072 KB Output is correct - L* = 40
20 Correct 48 ms 3056 KB Output is correct - L* = 40
21 Correct 48 ms 3072 KB Output is correct - L* = 40
22 Correct 50 ms 3056 KB Output is correct - L* = 40
23 Correct 49 ms 3072 KB Output is correct - L* = 40
24 Correct 48 ms 3056 KB Output is correct - L* = 40
25 Correct 48 ms 3056 KB Output is correct - L* = 40
26 Correct 49 ms 3072 KB Output is correct - L* = 40
27 Correct 48 ms 3088 KB Output is correct - L* = 40
28 Correct 49 ms 3056 KB Output is correct - L* = 40
29 Correct 48 ms 3072 KB Output is correct - L* = 40
30 Correct 48 ms 3056 KB Output is correct - L* = 40
31 Correct 48 ms 3072 KB Output is correct - L* = 40
32 Correct 49 ms 3072 KB Output is correct - L* = 40
33 Correct 48 ms 3072 KB Output is correct - L* = 40
34 Correct 49 ms 3056 KB Output is correct - L* = 40
35 Correct 56 ms 3064 KB Output is correct - L* = 40
36 Correct 49 ms 3072 KB Output is correct - L* = 40
37 Correct 50 ms 3056 KB Output is correct - L* = 40
38 Correct 48 ms 3056 KB Output is correct - L* = 40
39 Correct 48 ms 3072 KB Output is correct - L* = 40
40 Correct 52 ms 3072 KB Output is correct - L* = 40