답안 #311265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
311265 2020-10-09T19:45:15 Z CaroLinda Broken Device (JOI17_broken_device) C++14
85 / 100
57 ms 3328 KB
#include "Annalib.h"
#include <bits/stdc++.h>

#define ll long long 

using namespace std ;

ll pot[38] ;

void Anna( int N, long long X, int K, int P[] )
{
	pot[0] = 1LL ;
	for(int i = 1 ; i <= 37 ; i++ )
		pot[i] = pot[i-1]*3LL ;

	vector<bool> isBroken(N, false ) ;
	for(int i = 0 ; i <  K ; i++ ) isBroken[ P[i] ] = true ;

	vector<int> base3( 38, 0 ) ;
	for(int i = 37 ; i >= 0 ; i-- )
	{
		base3[i] = X/pot[i] ;
		X -= pot[i] * base3[i] ;
	}

	//01 = 0
	//10 = 1
	//11 = 2

	for(int i = 0, ptr = 0 ; i+1 < N ; i += 2 , ptr++ )
	{

		if( ptr > 37 )
		{
			Set(i,0);
			Set(i+1,0) ;
			continue ;
		}

		if(isBroken[i] && isBroken[i+1]) 
		{
			Set(i,0) ;
			Set(i+1,0) ;
			ptr-- ;
			continue ;
		}

		if(isBroken[i])
		{
			Set(i,0) ;

			if( base3[ptr] == 0 )
				Set(i+1, 1) ;
			else 
			{
				ptr-- ;
				Set(i+1,0) ;
			}
		}
		else if( isBroken[i+1] )
		{

			Set(i+1,0) ;

			if( base3[ptr] == 1 )
				Set(i,1) ;
			else 
			{
				ptr-- ;
				Set(i,0) ;
			}

		}
		else
		{
			if( base3[ptr] == 0 )
			{
				Set(i,0) ;
				Set(i+1,1) ;
			}
			else if(base3[ptr] == 1)
			{
				Set(i,1) ;
				Set(i+1,0) ;
			}
			else 
			{
				Set(i,1) ;
				Set(i+1,1) ;
			}
		}

	}

}
#include "Brunolib.h"
#include <bits/stdc++.h>

#define ll long long

using namespace std ;

ll pott[38] ;

long long Bruno( int N, int A[] )
{
  	pott[0] = 1LL ;
	for(int i = 1 ; i <= 37 ; i++ )
		pott[i] = pott[i-1]*3LL ;

	ll tot = 0LL ;

	for(int i = 0, ptr = 0 ; i+1 < N && ptr <= 37 ; i += 2 , ptr++ )
	{

		if( A[i] == 0 && A[i+1] == 0)
		{
			ptr-- ;
			continue ;			
		}

		if( A[i] == 1 && A[i+1] == 0 )
			tot += pott[ptr] ;
		else if( A[i] == 1 && A[i+1] == 1 )
			tot += 2LL*pott[ptr] ;

	}

	return tot ;

}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
2 Partially correct 46 ms 3328 KB Output is partially correct - L* = 37
3 Partially correct 45 ms 3328 KB Output is partially correct - L* = 37
4 Partially correct 47 ms 3328 KB Output is partially correct - L* = 37
5 Partially correct 57 ms 3312 KB Output is partially correct - L* = 37
6 Partially correct 47 ms 3328 KB Output is partially correct - L* = 37
7 Partially correct 46 ms 3328 KB Output is partially correct - L* = 37
8 Partially correct 47 ms 3312 KB Output is partially correct - L* = 37
9 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
10 Partially correct 46 ms 3224 KB Output is partially correct - L* = 37
11 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
12 Partially correct 46 ms 3312 KB Output is partially correct - L* = 37
13 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
14 Partially correct 48 ms 3328 KB Output is partially correct - L* = 37
15 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
16 Partially correct 46 ms 3312 KB Output is partially correct - L* = 37
17 Partially correct 46 ms 3328 KB Output is partially correct - L* = 37
18 Partially correct 47 ms 3328 KB Output is partially correct - L* = 37
19 Partially correct 48 ms 3328 KB Output is partially correct - L* = 37
20 Partially correct 48 ms 3312 KB Output is partially correct - L* = 37
21 Partially correct 47 ms 3312 KB Output is partially correct - L* = 37
22 Partially correct 45 ms 3312 KB Output is partially correct - L* = 38
23 Partially correct 46 ms 3312 KB Output is partially correct - L* = 37
24 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
25 Partially correct 47 ms 3312 KB Output is partially correct - L* = 37
26 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
27 Partially correct 47 ms 3312 KB Output is partially correct - L* = 37
28 Partially correct 46 ms 3328 KB Output is partially correct - L* = 37
29 Partially correct 45 ms 3328 KB Output is partially correct - L* = 37
30 Partially correct 45 ms 3328 KB Output is partially correct - L* = 37
31 Partially correct 47 ms 3328 KB Output is partially correct - L* = 38
32 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
33 Partially correct 45 ms 3312 KB Output is partially correct - L* = 37
34 Partially correct 45 ms 3328 KB Output is partially correct - L* = 37
35 Partially correct 44 ms 3328 KB Output is partially correct - L* = 37
36 Partially correct 45 ms 3328 KB Output is partially correct - L* = 37
37 Partially correct 46 ms 3312 KB Output is partially correct - L* = 37
38 Partially correct 46 ms 3312 KB Output is partially correct - L* = 37
39 Partially correct 46 ms 3328 KB Output is partially correct - L* = 37
40 Partially correct 46 ms 3328 KB Output is partially correct - L* = 37