제출 #113952

#제출 시각아이디문제언어결과실행 시간메모리
113952anaykBroken Device (JOI17_broken_device)C++14
0 / 100
2075 ms384 KiB
#include "Annalib.h"
#include <iostream>

#define LOGX 60

void Anna(int N, long long X, int K, int P[])
{
	int bin[LOGX];
	long long pow[LOGX];
	
	pow[0] = 1;
	for(int i = 1; i < LOGX; i++)
		pow[i] = pow[i-1]*2;
	
	for(int i = LOGX - 1; i >= 0; i++)
	{
		if(pow[i] <= X)
		{
			bin[i] = 1;
			X -= pow[i];
		}
		else
			bin[i] = 0;
	}
	
	int cur = 0;
	int ptr = 0;
	int next = 0;
	
	while(ptr < 60)
	{
		if(P[next] - cur < 3)
		{
			Set(cur, 0);
			cur++;
		}
		else
		{
			Set(cur, 1);
			cur++;
			for(int i = 0; i < 2; i++)
				Set(cur++, bin[ptr++]);
		}
		
		if(P[next] < cur)
			next++;
	}
	
	while(cur < N)
	{
		Set(cur, 0);
		cur++;
	}
}
#include "Brunolib.h"

#define LOGX 60

long long Bruno(int N, int A[])
{
	long long pow[LOGX];
	
	pow[0] = 1;
	for(int i = 1; i < LOGX; i++)
		pow[i] = pow[i-1]*2;
	
	long long X = 0;
	int cur = 0;
	for(int i = 0; i < N; i++)
	{
		if(A[i] == 1)
		{
			for(int j = 0; j < 2; j++)
				if(A[++i])
					X += pow[cur++];
		}
	}
	
	return X;
}
#Verdict Execution timeMemoryGrader output
Fetching results...