Submission #261494

# Submission time Handle Problem Language Result Execution time Memory
261494 2020-08-11T19:09:09 Z arnold518 Broken Device (JOI17_broken_device) C++14
100 / 100
74 ms 3072 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
static const int MAXN = 150;
static const int MAXK = 40;
 
static int N, K, *P;
static ll X;
static int A[MAXN+10];

static int PP[160];
static int QQ[160];

static int cnt=1;

void Anna(int _N, ll _X, int _K, int _P[])
{
	N=_N; X=_X; K=_K; P=_P;

	for(int i=0; i<N; i++) PP[i]=i;
	srand(cnt++);
	random_shuffle(PP, PP+N);
	for(int i=0; i<N; i++) QQ[PP[i]]=i;

	for(int i=0; i<K; i++) A[QQ[P[i]]]=-1;
 

	ll now=X;
	for(int i=0; i<N; i+=2)
	{
		if(A[i]==-1 && A[i+1]==-1) A[i]=0, A[i+1]=0;
		else if(A[i]==-1 && now%3==0) A[i]=0, A[i+1]=1, now/=3;
		else if(A[i+1]==-1 && now%3==1) A[i]=1, A[i+1]=0, now/=3;
		else if(A[i]==-1 || A[i+1]==-1) A[i]=0, A[i+1]=0;
		else if(now%3==0) A[i]=0, A[i+1]=1, now/=3;
		else if(now%3==1) A[i]=1, A[i+1]=0, now/=3;
		else if(now%3==2) A[i]=1, A[i+1]=1, now/=3;
	}
	for(int i=0; i<N; i++) Set(PP[i], A[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
static int N, *A;

static int PP[160];
static int QQ[160];

static int cnt=1;

ll Bruno(int _N, int _A[])
{
	N=_N; A=_A;
	ll ret=0;

	for(int i=0; i<N; i++) PP[i]=i;
	srand(cnt++);
	random_shuffle(PP, PP+N);
	for(int i=0; i<N; i++) QQ[PP[i]]=i;

	for(int i=N-2; i>=0; i-=2)
	{
		if(A[PP[i]]==0 && A[PP[i+1]]==0) continue;
		if(A[PP[i]]==0 && A[PP[i+1]]==1) ret=ret*3+0;
		if(A[PP[i]]==1 && A[PP[i+1]]==0) ret=ret*3+1;
		if(A[PP[i]]==1 && A[PP[i+1]]==1) ret=ret*3+2;
	}
	return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 54 ms 3056 KB Output is correct - L* = 40
2 Correct 60 ms 3056 KB Output is correct - L* = 40
3 Correct 60 ms 3056 KB Output is correct - L* = 40
4 Correct 55 ms 3056 KB Output is correct - L* = 40
5 Correct 54 ms 3056 KB Output is correct - L* = 40
6 Correct 51 ms 2992 KB Output is correct - L* = 40
7 Correct 58 ms 3056 KB Output is correct - L* = 40
8 Correct 56 ms 3056 KB Output is correct - L* = 40
9 Correct 56 ms 3072 KB Output is correct - L* = 40
10 Correct 59 ms 3056 KB Output is correct - L* = 40
11 Correct 54 ms 3056 KB Output is correct - L* = 40
12 Correct 54 ms 3072 KB Output is correct - L* = 40
13 Correct 54 ms 3056 KB Output is correct - L* = 40
14 Correct 54 ms 3056 KB Output is correct - L* = 40
15 Correct 57 ms 3056 KB Output is correct - L* = 40
16 Correct 54 ms 3056 KB Output is correct - L* = 40
17 Correct 56 ms 3056 KB Output is correct - L* = 40
18 Correct 54 ms 3056 KB Output is correct - L* = 40
19 Correct 55 ms 3072 KB Output is correct - L* = 40
20 Correct 54 ms 3056 KB Output is correct - L* = 40
21 Correct 55 ms 3056 KB Output is correct - L* = 40
22 Correct 54 ms 3072 KB Output is correct - L* = 40
23 Correct 55 ms 3056 KB Output is correct - L* = 40
24 Correct 55 ms 3072 KB Output is correct - L* = 40
25 Correct 56 ms 3056 KB Output is correct - L* = 40
26 Correct 54 ms 3072 KB Output is correct - L* = 40
27 Correct 54 ms 3072 KB Output is correct - L* = 40
28 Correct 60 ms 3056 KB Output is correct - L* = 40
29 Correct 54 ms 3072 KB Output is correct - L* = 40
30 Correct 54 ms 3056 KB Output is correct - L* = 40
31 Correct 55 ms 3056 KB Output is correct - L* = 40
32 Correct 74 ms 3056 KB Output is correct - L* = 40
33 Correct 57 ms 3016 KB Output is correct - L* = 40
34 Correct 54 ms 3056 KB Output is correct - L* = 40
35 Correct 59 ms 3056 KB Output is correct - L* = 40
36 Correct 54 ms 3056 KB Output is correct - L* = 40
37 Correct 54 ms 3072 KB Output is correct - L* = 40
38 Correct 56 ms 3056 KB Output is correct - L* = 40
39 Correct 58 ms 3056 KB Output is correct - L* = 40
40 Correct 56 ms 3072 KB Output is correct - L* = 40