답안 #61210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61210 2018-07-25T11:22:41 Z babo Broken Device (JOI17_broken_device) C++14
100 / 100
84 ms 3744 KB
#include "Annalib.h"
#include <bits/stdc++.h>
#define L long long

using namespace std;

void Set(int,int);

int a[150];


void Anna(int N,L X,int K,int P[]){
	
	int i;
	L bit=1;
	
	for(i=0;i<N;i++)
	{
		a[i]=0;
	}
	for(i=0;i<K;i++)
	{
		a[P[i]]=-1;
	}
	for(i=0;i<N;i+=3)
	{
		//printf("%lld\n",i);
		if(X<bit) break;
		L sum=a[i]+a[i+1]+a[i+2];
		if(sum<=-2) continue;
		if(sum==0)
		{
			switch(X/bit%4){
				case 0:
					a[i]=a[i+1]=a[i+2]=1;
					break;
				case 1:
					a[i+2]=1;
					break;
				case 2:
					a[i]=a[i+1]=1;
					break;
				case 3:
					a[i+1]=a[i+2]=1;
			}
			bit<<=2;
		}
		else
		{
			if(a[i]==-1)
			{
				if(X/bit%2==0)
				{
					a[i+1]=1;
					bit<<=1;
				}
				else
				{
					if(X/bit%4==1)
					{
						a[i+2]=1;
					}
					else
					{
						a[i+1]=a[i+2]=1;
					}
					bit<<=2;
				}
			}
			else if(a[i+1]==-1)
			{
				if(X/bit%2)
				{
					a[i]=1;
				}
				else
				{
					a[i]=a[i+2]=1;
				}
				bit<<=1;
			}
			else
			{
				if(X/bit%2)
				{
					a[i]=1;
				}
				else
				{
					a[i+1]=1;
				}
				bit<<=1;
			}
		}
		if(X<bit) break;
	}
	for(i=0;i<N;i++)
	{
		if(a[i]==1) Set(i,1);
		else Set(i,0);
	}
}

/*
int p[100010];
int aa[100010];

void Set(int loc,int val){
	aa[loc]=val;
}
L con[8]={
	0,1,0,3,1,0,2,0
};
L shi[8]{
	0,2,1,2,1,1,2,2
};

L Bruno(int N,int A[]){
	L ret=0,i,bit=1;
	for(i=0;i<N;i+=3)
	{
		L temp=A[i]*4+A[i+1]*2+A[i+2];
		ret+=bit*con[temp];
		//printf("%lld %lld\n",bit,temp);
		bit<<=shi[temp];
	}
	return ret;
}

int main()
{
	L n,k,x;
	
	scanf("%lld %lld %lld",&n,&k,&x);
	for(int i=0;i<k;i++)
	{
		scanf("%lld",&p[i]);
	}
	Anna(n,x,k,p);
	for(int i=0;i<n;i++)
	{
		printf("%d ",aa[i]);
	}
	puts("");
	printf("%lld ",Bruno(n,aa));
}
//*/
#include "Brunolib.h"
#include <bits/stdc++.h>
#define L long long

using namespace std;

L con[8]={
	0,1,0,3,1,0,2,0
};
L shi[8]{
	0,2,1,2,1,1,2,2
};

L Bruno(int N,int A[]){
	L ret=0,i,bit=1;
	for(i=0;i<N;i+=3)
	{
		L temp=A[i]*4+A[i+1]*2+A[i+2];
		ret+=bit*con[temp];
		//printf("%lld %lld\n",bit,temp);
		bit<<=shi[temp];
	}
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 3056 KB Output is correct - L* = 40
2 Correct 60 ms 3448 KB Output is correct - L* = 40
3 Correct 47 ms 3448 KB Output is correct - L* = 40
4 Correct 45 ms 3448 KB Output is correct - L* = 40
5 Correct 52 ms 3688 KB Output is correct - L* = 40
6 Correct 52 ms 3688 KB Output is correct - L* = 40
7 Correct 48 ms 3696 KB Output is correct - L* = 40
8 Correct 57 ms 3696 KB Output is correct - L* = 40
9 Correct 73 ms 3696 KB Output is correct - L* = 40
10 Correct 65 ms 3696 KB Output is correct - L* = 40
11 Correct 84 ms 3696 KB Output is correct - L* = 40
12 Correct 57 ms 3704 KB Output is correct - L* = 40
13 Correct 48 ms 3704 KB Output is correct - L* = 40
14 Correct 46 ms 3704 KB Output is correct - L* = 40
15 Correct 58 ms 3704 KB Output is correct - L* = 40
16 Correct 48 ms 3704 KB Output is correct - L* = 40
17 Correct 51 ms 3704 KB Output is correct - L* = 40
18 Correct 53 ms 3744 KB Output is correct - L* = 40
19 Correct 57 ms 3744 KB Output is correct - L* = 40
20 Correct 66 ms 3744 KB Output is correct - L* = 40
21 Correct 58 ms 3744 KB Output is correct - L* = 40
22 Correct 79 ms 3744 KB Output is correct - L* = 40
23 Correct 61 ms 3744 KB Output is correct - L* = 40
24 Correct 47 ms 3744 KB Output is correct - L* = 40
25 Correct 60 ms 3744 KB Output is correct - L* = 40
26 Correct 54 ms 3744 KB Output is correct - L* = 40
27 Correct 50 ms 3744 KB Output is correct - L* = 40
28 Correct 57 ms 3744 KB Output is correct - L* = 40
29 Correct 50 ms 3744 KB Output is correct - L* = 40
30 Correct 49 ms 3744 KB Output is correct - L* = 40
31 Correct 63 ms 3744 KB Output is correct - L* = 40
32 Correct 55 ms 3744 KB Output is correct - L* = 40
33 Correct 54 ms 3744 KB Output is correct - L* = 40
34 Correct 56 ms 3744 KB Output is correct - L* = 40
35 Correct 56 ms 3744 KB Output is correct - L* = 40
36 Correct 56 ms 3744 KB Output is correct - L* = 40
37 Correct 56 ms 3744 KB Output is correct - L* = 40
38 Correct 52 ms 3744 KB Output is correct - L* = 40
39 Correct 53 ms 3744 KB Output is correct - L* = 40
40 Correct 59 ms 3744 KB Output is correct - L* = 40