Submission #411861

# Submission time Handle Problem Language Result Execution time Memory
411861 2021-05-26T07:10:11 Z amoo_safar Broken Device (JOI17_broken_device) C++17
85 / 100
45 ms 2396 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(time(0));
	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);
	// }
	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;
		}
		X /= 3;
		// cerr << "# " << idx << '\n';
		Set(i, (idx + 1) / 2);
		Set(i + 1, (idx + 1) % 2);
	}

	// 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(time(0));
	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;
	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];
		res *= 3;
		res += rd;
	}
	// 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 Partially correct 40 ms 2200 KB Output is partially correct - L* = 37
2 Partially correct 40 ms 2260 KB Output is partially correct - L* = 37
3 Partially correct 39 ms 2320 KB Output is partially correct - L* = 37
4 Partially correct 40 ms 2196 KB Output is partially correct - L* = 37
5 Partially correct 40 ms 2260 KB Output is partially correct - L* = 37
6 Partially correct 39 ms 2196 KB Output is partially correct - L* = 37
7 Partially correct 39 ms 2324 KB Output is partially correct - L* = 37
8 Partially correct 39 ms 2320 KB Output is partially correct - L* = 37
9 Partially correct 40 ms 2332 KB Output is partially correct - L* = 37
10 Partially correct 39 ms 2240 KB Output is partially correct - L* = 37
11 Partially correct 41 ms 2208 KB Output is partially correct - L* = 37
12 Partially correct 39 ms 2236 KB Output is partially correct - L* = 37
13 Partially correct 39 ms 2388 KB Output is partially correct - L* = 37
14 Partially correct 40 ms 2268 KB Output is partially correct - L* = 37
15 Partially correct 39 ms 2280 KB Output is partially correct - L* = 37
16 Partially correct 40 ms 2372 KB Output is partially correct - L* = 37
17 Partially correct 45 ms 2280 KB Output is partially correct - L* = 37
18 Partially correct 40 ms 2196 KB Output is partially correct - L* = 37
19 Partially correct 40 ms 2384 KB Output is partially correct - L* = 37
20 Partially correct 40 ms 2284 KB Output is partially correct - L* = 37
21 Partially correct 38 ms 2312 KB Output is partially correct - L* = 37
22 Partially correct 39 ms 2376 KB Output is partially correct - L* = 38
23 Partially correct 40 ms 2248 KB Output is partially correct - L* = 37
24 Partially correct 41 ms 2332 KB Output is partially correct - L* = 37
25 Partially correct 40 ms 2292 KB Output is partially correct - L* = 37
26 Partially correct 38 ms 2236 KB Output is partially correct - L* = 37
27 Partially correct 41 ms 2244 KB Output is partially correct - L* = 37
28 Partially correct 39 ms 2340 KB Output is partially correct - L* = 37
29 Partially correct 40 ms 2356 KB Output is partially correct - L* = 37
30 Partially correct 41 ms 2284 KB Output is partially correct - L* = 37
31 Partially correct 40 ms 2304 KB Output is partially correct - L* = 38
32 Partially correct 38 ms 2232 KB Output is partially correct - L* = 37
33 Partially correct 39 ms 2336 KB Output is partially correct - L* = 37
34 Partially correct 40 ms 2396 KB Output is partially correct - L* = 37
35 Partially correct 40 ms 2252 KB Output is partially correct - L* = 37
36 Partially correct 39 ms 2336 KB Output is partially correct - L* = 37
37 Partially correct 43 ms 2392 KB Output is partially correct - L* = 37
38 Partially correct 40 ms 2264 KB Output is partially correct - L* = 37
39 Partially correct 38 ms 2248 KB Output is partially correct - L* = 37
40 Partially correct 40 ms 2392 KB Output is partially correct - L* = 37