Submission #411865

# Submission time Handle Problem Language Result Execution time Memory
411865 2021-05-26T07:17:06 Z amoo_safar Broken Device (JOI17_broken_device) C++17
100 / 100
50 ms 2484 KB
#include "Annalib.h"

#include <bits/stdc++.h>

using namespace std;

const int Z = 75;
vector< vector<int> > V;
bool init = false;

void Init(){
	srand(58);
	vector<int> per = {0, 1, 2};
	for(int i = 0; i < Z; i++){
		random_shuffle(per.begin(), per.end());
		V.push_back(per);
	}
	init = true;
}

void Anna( int n, long long X, int K, int P[] ){
	if(!init)
		Init();
	
	assert(n == 150);
	vector<int> mk(n, 0);
	for(int i = 0; i < K; i++)
		mk[P[i]] = 1;
	// for(int i = 0; i < N; i++){
	// 	if(i == N - 1){
	// 		Set(i, 0);
	// 		continue;
	// 	}
	// 	if(mk[i] || mk[i + 1])
	// 		Set(i, 0);
	// }
	// cerr << "^ ";
	for(int i = 0; i < n; i += 2){
		if(mk[i] && mk[i + 1]){
			Set(i, 0);
			Set(i + 1, 0);
			continue;
		}
		int rt = X % 3;
		int idx = 0;
		for(int j = 0; j < 3; j++)
			if(V[i / 2][j] == rt)
				idx = j;
		// assert(rt == idx);
		int br = mk[i] + mk[i] + mk[i + 1];
		if(br & (idx + 1)){
			Set(i, 0);
			Set(i + 1, 0);	
			continue;
		}
		// cerr << idx;
		X /= 3;
		// cerr << "# " << idx << '\n';
		Set(i, (idx + 1) / 2);
		Set(i + 1, (idx + 1) % 2);
	}
	// cerr << '\n';
	// cerr << "!! ";
	// for(int i = 0; i < 4; i++){
	// 	cerr << "(";
	// 	for(int j = 0; j < 3; j++)
	// 		cerr << V[i][j] << ",)"[j == 2];
	// 	// cerr << '\n';
	// }
	// cerr << '\n';
}
#include "Brunolib.h"

#include <bits/stdc++.h>

using namespace std;

const int Z = 75;
vector< vector<int> > V2;
bool init2 = false;

void Init2(){
	srand(58);
	vector<int> per = {0, 1, 2};
	for(int i = 0; i < Z; i++){
		random_shuffle(per.begin(), per.end());
		V2.push_back(per);
	}
	init2 = true;
}

long long Bruno( int n, int A[] ){
	if(!init2)
		Init2();
	assert(n == 150);
	long long res = 0;
	// cerr << "^^ ";
	for(int i = n - 2; i >= 0; i -= 2){
		if(A[i] == 0 && A[i + 1] == 0) continue;
		int rd = A[i] + A[i] + A[i + 1] - 1;
		rd = V2[i / 2][rd];
		// cerr << rd;
		res *= 3;
		res += rd;
	}
	// cerr << '\n';
	// cerr << "!! " << res << '\n';
	// cerr << "## ";
	// for(int i = 0; i < 4; i++){
	// 	cerr << "(";
	// 	for(int j = 0; j < 3; j++)
	// 		cerr << V2[i][j] << ",)"[j == 2];
	// 	// cerr << '\n';
	// }
	// cerr << '\n';
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2332 KB Output is correct - L* = 40
2 Correct 48 ms 2192 KB Output is correct - L* = 40
3 Correct 44 ms 2312 KB Output is correct - L* = 40
4 Correct 40 ms 2396 KB Output is correct - L* = 40
5 Correct 41 ms 2204 KB Output is correct - L* = 40
6 Correct 39 ms 2284 KB Output is correct - L* = 40
7 Correct 40 ms 2296 KB Output is correct - L* = 40
8 Correct 41 ms 2484 KB Output is correct - L* = 40
9 Correct 50 ms 2224 KB Output is correct - L* = 40
10 Correct 41 ms 2260 KB Output is correct - L* = 40
11 Correct 40 ms 2336 KB Output is correct - L* = 40
12 Correct 39 ms 2256 KB Output is correct - L* = 40
13 Correct 41 ms 2356 KB Output is correct - L* = 40
14 Correct 45 ms 2332 KB Output is correct - L* = 40
15 Correct 48 ms 2312 KB Output is correct - L* = 40
16 Correct 40 ms 2244 KB Output is correct - L* = 40
17 Correct 43 ms 2280 KB Output is correct - L* = 40
18 Correct 39 ms 2280 KB Output is correct - L* = 40
19 Correct 41 ms 2196 KB Output is correct - L* = 40
20 Correct 40 ms 2324 KB Output is correct - L* = 40
21 Correct 40 ms 2328 KB Output is correct - L* = 40
22 Correct 40 ms 2376 KB Output is correct - L* = 40
23 Correct 40 ms 2292 KB Output is correct - L* = 40
24 Correct 40 ms 2328 KB Output is correct - L* = 40
25 Correct 40 ms 2432 KB Output is correct - L* = 40
26 Correct 42 ms 2248 KB Output is correct - L* = 40
27 Correct 41 ms 2484 KB Output is correct - L* = 40
28 Correct 41 ms 2332 KB Output is correct - L* = 40
29 Correct 43 ms 2404 KB Output is correct - L* = 40
30 Correct 46 ms 2276 KB Output is correct - L* = 40
31 Correct 43 ms 2228 KB Output is correct - L* = 40
32 Correct 48 ms 2200 KB Output is correct - L* = 40
33 Correct 43 ms 2224 KB Output is correct - L* = 40
34 Correct 40 ms 2332 KB Output is correct - L* = 40
35 Correct 43 ms 2328 KB Output is correct - L* = 40
36 Correct 40 ms 2208 KB Output is correct - L* = 40
37 Correct 39 ms 2224 KB Output is correct - L* = 40
38 Correct 40 ms 2272 KB Output is correct - L* = 40
39 Correct 39 ms 2244 KB Output is correct - L* = 40
40 Correct 41 ms 2196 KB Output is correct - L* = 40