Submission #990641

# Submission time Handle Problem Language Result Execution time Memory
990641 2024-05-30T21:16:18 Z Saul0906 Broken Device (JOI17_broken_device) C++14
100 / 100
31 ms 2692 KB
#include "Annalib.h"
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a: b)
#define repr(a,b,c) for(int a=b-1; a>c-1; a--)
 
using namespace std;


void Anna( int N, long long X, int K, int P[] ){
	mt19937_64 rnd(123456789);
	bool b[150]{};
	int pp[150];
	rep(i,0,150) pp[i]=i;
	shuffle(pp,pp+150,rnd);
	rep(i,0,K) b[P[i]]=1;
	int d[38]{}, p=0;
	while(X){
		d[p++]=X%3;
		X/=3;
	}
	p=0;
	for( int i = 0; i < N; i+=2 ){
		if(((!b[pp[i]] && !b[pp[i+1]]) || (!b[pp[i]] && d[p]==1) || (!b[pp[i+1]] && d[p]==2)) && p<38){
			if(d[p]==0) Set(pp[i],1), Set(pp[i+1],1); //1,1 = 0
			if(d[p]==1) Set(pp[i],1), Set(pp[i+1],0); //1,0 = 1
			if(d[p]==2) Set(pp[i],0), Set(pp[i+1],1); //0,1 = 2
			p++;
		}else Set(pp[i],0), Set(pp[i+1],0);
	}
}
#include "Brunolib.h"
#define rep(a,b,c) for(int a=b; a<c; a++)
#define ll long long
#include <bits/stdc++.h>
 
using namespace std;

ll fpow(ll x, ll y){
	if(!y) return 1;
	if(y&1) return fpow(x,y-1)*x;
	ll z=fpow(x,y/2);
	return z*z;
}
 
long long Bruno( int N, int A[] ){
	mt19937_64 rnd(123456789);
	ll d[38]{}, p=0;
	ll X=0;
	int pp[150];
	rep(i,0,150) pp[i]=i;
	shuffle(pp,pp+150,rnd);
	rep(i,0,N){
		if(A[pp[i]]==0 && A[pp[i+1]]==0){
			i++;
			continue;
		}
		if(A[pp[i]]==1 && A[pp[i+1]]==1) d[p++]=0;
		if(A[pp[i]]==1 && A[pp[i+1]]==0) d[p++]=1;
		if(A[pp[i]]==0 && A[pp[i+1]]==1) d[p++]=2;
		i++;
		if(p==38) break;
	}
	rep(i,0,38){
		X+=d[i]*fpow(3,i);
	}
	return X;
}
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2372 KB Output is correct - L* = 40
2 Correct 24 ms 2692 KB Output is correct - L* = 40
3 Correct 25 ms 2476 KB Output is correct - L* = 40
4 Correct 26 ms 2476 KB Output is correct - L* = 40
5 Correct 31 ms 2368 KB Output is correct - L* = 40
6 Correct 24 ms 2552 KB Output is correct - L* = 40
7 Correct 24 ms 2400 KB Output is correct - L* = 40
8 Correct 24 ms 2484 KB Output is correct - L* = 40
9 Correct 24 ms 2396 KB Output is correct - L* = 40
10 Correct 24 ms 2400 KB Output is correct - L* = 40
11 Correct 26 ms 2396 KB Output is correct - L* = 40
12 Correct 30 ms 2400 KB Output is correct - L* = 40
13 Correct 24 ms 2404 KB Output is correct - L* = 40
14 Correct 27 ms 2404 KB Output is correct - L* = 40
15 Correct 27 ms 2496 KB Output is correct - L* = 40
16 Correct 25 ms 2484 KB Output is correct - L* = 40
17 Correct 24 ms 2396 KB Output is correct - L* = 40
18 Correct 24 ms 2488 KB Output is correct - L* = 40
19 Correct 24 ms 2392 KB Output is correct - L* = 40
20 Correct 28 ms 2396 KB Output is correct - L* = 40
21 Correct 28 ms 2484 KB Output is correct - L* = 40
22 Correct 24 ms 2620 KB Output is correct - L* = 40
23 Correct 25 ms 2488 KB Output is correct - L* = 40
24 Correct 24 ms 2396 KB Output is correct - L* = 40
25 Correct 24 ms 2396 KB Output is correct - L* = 40
26 Correct 25 ms 2484 KB Output is correct - L* = 40
27 Correct 26 ms 2536 KB Output is correct - L* = 40
28 Correct 24 ms 2396 KB Output is correct - L* = 40
29 Correct 24 ms 2480 KB Output is correct - L* = 40
30 Correct 25 ms 2396 KB Output is correct - L* = 40
31 Correct 24 ms 2472 KB Output is correct - L* = 40
32 Correct 24 ms 2484 KB Output is correct - L* = 40
33 Correct 28 ms 2396 KB Output is correct - L* = 40
34 Correct 25 ms 2372 KB Output is correct - L* = 40
35 Correct 27 ms 2400 KB Output is correct - L* = 40
36 Correct 24 ms 2400 KB Output is correct - L* = 40
37 Correct 24 ms 2368 KB Output is correct - L* = 40
38 Correct 24 ms 2392 KB Output is correct - L* = 40
39 Correct 24 ms 2392 KB Output is correct - L* = 40
40 Correct 25 ms 2396 KB Output is correct - L* = 40