Submission #260359

# Submission time Handle Problem Language Result Execution time Memory
260359 2020-08-10T06:55:18 Z 송준혁(#5057) Broken Device (JOI17_broken_device) C++14
100 / 100
49 ms 3328 KB
#include "Annalib.h"
static int A[160];

void Anna(int N, long long X, int K, int P[]){
	int cnt=0;
	for (int i=0; i<N; i++) A[i] = 0;
	for (int i=0; i<K; i++) A[P[i]] = 1;
	for (int i=0; i<N; i+=3){
		if (A[i]+A[i+1]+A[i+2] == 0 && cnt<60){
			if ((X&(1ll<<cnt)) && (X&(1ll<<cnt+1))) A[i]=A[i+1]=A[i+2]=1;
			if ((X&(1ll<<cnt)) && !(X&(1ll<<cnt+1))) A[i]=A[i+2]=1, A[i+1]=0;
			if (!(X&(1ll<<cnt)) && (X&(1ll<<cnt+1))) A[i]=A[i+2]=0, A[i+1]=1;
			if (!(X&(1ll<<cnt)) && !(X&(1ll<<cnt+1))) A[i+1]=A[i+2]=1, A[i]=0;
			cnt += 2;
		}
		else if (A[i]+A[i+1]+A[i+2] == 1 && cnt<60){
			if (X&(1ll<<cnt)){
				if (A[i+2]) A[i]=A[i+1]=1, A[i+2]=0;
				else A[i+2]=1, A[i]=A[i+1]=0;
				cnt++;
			}
			else if (A[i]){
				if (X&(1ll<<cnt+1)) A[i]=A[i+2]=0, A[i+1]=1;
				else A[i]=0, A[i+1]=A[i+2]=1;
				cnt+=2;
			}
			else A[i]=1, A[i+1]=A[i+2]=0, cnt++;
		}
		else A[i]=A[i+1]=A[i+2]=0;
	}
	for (int i=0; i<N; i++) Set(i, A[i]);
}
#include "Brunolib.h"

long long Bruno(int N, int A[]){
	long long ans=0;
	int t=0;
	for (int i=0; i<N; i+=3){
		if (A[i] && A[i+1] && A[i+2]) ans|=(1ll<<t), t++, ans|=(1ll<<t), t++;
		if (A[i] && A[i+1] && !A[i+2]) ans|=(1ll<<t), t++;
		if (A[i] && !A[i+1] && A[i+2]) ans|=(1ll<<t), t+=2;
		if (A[i] && !A[i+1] && !A[i+2]) t++;
		if (!A[i] && A[i+1] && A[i+2]) t+=2;
		if (!A[i] && A[i+1] && !A[i+2]) t++, ans|=(1ll<<t), t++;
		if (!A[i] && !A[i+1] && A[i+2]) ans|=(1ll<<t), t++;
	}
	return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:10:38: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    if ((X&(1ll<<cnt)) && (X&(1ll<<cnt+1))) A[i]=A[i+1]=A[i+2]=1;
                                   ~~~^~
Anna.cpp:11:39: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    if ((X&(1ll<<cnt)) && !(X&(1ll<<cnt+1))) A[i]=A[i+2]=1, A[i+1]=0;
                                    ~~~^~
Anna.cpp:12:39: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    if (!(X&(1ll<<cnt)) && (X&(1ll<<cnt+1))) A[i]=A[i+2]=0, A[i+1]=1;
                                    ~~~^~
Anna.cpp:13:40: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    if (!(X&(1ll<<cnt)) && !(X&(1ll<<cnt+1))) A[i+1]=A[i+2]=1, A[i]=0;
                                     ~~~^~
Anna.cpp:23:20: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
     if (X&(1ll<<cnt+1)) A[i]=A[i+2]=0, A[i+1]=1;
                 ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 42 ms 3072 KB Output is correct - L* = 40
2 Correct 42 ms 3056 KB Output is correct - L* = 40
3 Correct 42 ms 3072 KB Output is correct - L* = 40
4 Correct 46 ms 3072 KB Output is correct - L* = 40
5 Correct 48 ms 3072 KB Output is correct - L* = 40
6 Correct 41 ms 3072 KB Output is correct - L* = 40
7 Correct 46 ms 3072 KB Output is correct - L* = 40
8 Correct 47 ms 3056 KB Output is correct - L* = 40
9 Correct 42 ms 3056 KB Output is correct - L* = 40
10 Correct 41 ms 3072 KB Output is correct - L* = 40
11 Correct 41 ms 3072 KB Output is correct - L* = 40
12 Correct 42 ms 3056 KB Output is correct - L* = 40
13 Correct 43 ms 3072 KB Output is correct - L* = 40
14 Correct 41 ms 3056 KB Output is correct - L* = 40
15 Correct 42 ms 3056 KB Output is correct - L* = 40
16 Correct 42 ms 3072 KB Output is correct - L* = 40
17 Correct 41 ms 3072 KB Output is correct - L* = 40
18 Correct 41 ms 2856 KB Output is correct - L* = 40
19 Correct 43 ms 3056 KB Output is correct - L* = 40
20 Correct 41 ms 2880 KB Output is correct - L* = 40
21 Correct 41 ms 3056 KB Output is correct - L* = 40
22 Correct 41 ms 3072 KB Output is correct - L* = 40
23 Correct 44 ms 3056 KB Output is correct - L* = 40
24 Correct 42 ms 3064 KB Output is correct - L* = 40
25 Correct 44 ms 3056 KB Output is correct - L* = 40
26 Correct 42 ms 3056 KB Output is correct - L* = 40
27 Correct 41 ms 3056 KB Output is correct - L* = 40
28 Correct 41 ms 3072 KB Output is correct - L* = 40
29 Correct 43 ms 2944 KB Output is correct - L* = 40
30 Correct 42 ms 3072 KB Output is correct - L* = 40
31 Correct 43 ms 3056 KB Output is correct - L* = 40
32 Correct 49 ms 3056 KB Output is correct - L* = 40
33 Correct 41 ms 3072 KB Output is correct - L* = 40
34 Correct 42 ms 3056 KB Output is correct - L* = 40
35 Correct 43 ms 3328 KB Output is correct - L* = 40
36 Correct 42 ms 3072 KB Output is correct - L* = 40
37 Correct 46 ms 3072 KB Output is correct - L* = 40
38 Correct 41 ms 3064 KB Output is correct - L* = 40
39 Correct 41 ms 3072 KB Output is correct - L* = 40
40 Correct 42 ms 3072 KB Output is correct - L* = 40