답안 #411863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411863 2021-05-26T07:15:53 Z amoo_safar Broken Device (JOI17_broken_device) C++17
0 / 100
55 ms 2460 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);
	// }
	// 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(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;
	// 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2332 KB Output is correct - L* = 40
2 Correct 39 ms 2312 KB Output is correct - L* = 40
3 Correct 38 ms 2316 KB Output is correct - L* = 40
4 Correct 46 ms 2196 KB Output is correct - L* = 40
5 Correct 49 ms 2240 KB Output is correct - L* = 40
6 Correct 43 ms 2328 KB Output is correct - L* = 40
7 Correct 41 ms 2236 KB Output is correct - L* = 40
8 Correct 40 ms 2244 KB Output is correct - L* = 40
9 Correct 40 ms 2296 KB Output is correct - L* = 40
10 Correct 42 ms 2256 KB Output is correct - L* = 40
11 Correct 43 ms 2304 KB Output is correct - L* = 40
12 Correct 39 ms 2196 KB Output is correct - L* = 40
13 Correct 45 ms 2380 KB Output is correct - L* = 40
14 Correct 55 ms 2220 KB Output is correct - L* = 40
15 Correct 40 ms 2460 KB Output is correct - L* = 40
16 Correct 41 ms 2288 KB Output is correct - L* = 40
17 Correct 40 ms 2260 KB Output is correct - L* = 40
18 Partially correct 41 ms 2324 KB Output isn't correct - L* = 0
19 Correct 49 ms 2376 KB Output is correct - L* = 40
20 Correct 38 ms 2308 KB Output is correct - L* = 40
21 Correct 41 ms 2368 KB Output is correct - L* = 40
22 Correct 39 ms 2204 KB Output is correct - L* = 40
23 Correct 38 ms 2192 KB Output is correct - L* = 40
24 Correct 41 ms 2284 KB Output is correct - L* = 40
25 Correct 40 ms 2284 KB Output is correct - L* = 40
26 Correct 47 ms 2296 KB Output is correct - L* = 40
27 Correct 43 ms 2360 KB Output is correct - L* = 40
28 Correct 38 ms 2220 KB Output is correct - L* = 40
29 Correct 38 ms 2256 KB Output is correct - L* = 40
30 Correct 43 ms 2288 KB Output is correct - L* = 40
31 Correct 45 ms 2360 KB Output is correct - L* = 40
32 Partially correct 39 ms 2200 KB Output isn't correct - L* = 0
33 Correct 45 ms 2204 KB Output is correct - L* = 40
34 Correct 40 ms 2252 KB Output is correct - L* = 40
35 Correct 47 ms 2280 KB Output is correct - L* = 40
36 Correct 38 ms 2188 KB Output is correct - L* = 40
37 Correct 39 ms 2256 KB Output is correct - L* = 40
38 Correct 41 ms 2296 KB Output is correct - L* = 40
39 Correct 45 ms 2332 KB Output is correct - L* = 40
40 Correct 43 ms 2340 KB Output is correct - L* = 40