답안 #837254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837254 2023-08-25T08:39:57 Z TranGiaHuy1508 Broken Device (JOI17_broken_device) C++17
100 / 100
33 ms 2532 KB
#include <bits/stdc++.h>
using namespace std;

#include "Annalib.h"

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

namespace {
	ll SEED = 123456788;
	mt19937_64 rng(SEED);

	bool init = false;
	vector<vvi> mapping;

	void generate(){
		if (init) return;
		init = true;

		vvi M = {{1, 6}, {2, 5}, {3, 4}, {7}};
		for (int i = 0; i < 50; i++){
			vvi _M = M;
			shuffle(_M.begin(), _M.end(), rng);
			mapping.push_back(_M);
		}
	}
}

void Anna(int N, ll X, int K, int P[]){
	generate();

	vector<int> broken(N, 0);
	for (int i = 0; i < K; i++) broken[P[i]] = 1;

	// cout << "Anna: ";
	for (int i = 0; i < N; i += 3){
		vector<int> S(3);
		iota(S.begin(), S.end(), i);

		int valid = 7;
		for (int j = 0; j < 3; j++){
			if (broken[S[j]]) valid ^= (1 << j);
		}

		int ed = X & 3;
		int R = 0;
		for (auto mask: mapping[i/3][ed]){
			if ((valid & mask) == mask) R = mask;
		}

		for (int j = 0; j < 3; j++){
			Set(S[j], (R >> j) & 1);
			// cout << ((R >> j) & 1);
		}

		if (R > 0) X >>= 2;
	}
	// cout << "\n";
}
#include <bits/stdc++.h>
using namespace std;

#include "Brunolib.h"

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

namespace {
	ll SEED = 123456788;
	mt19937_64 rng(SEED);

	bool init = false;
	vector<vvi> mapping;

	void generate(){
		if (init) return;
		init = true;

		vvi M = {{1, 6}, {2, 5}, {3, 4}, {7}};
		for (int i = 0; i < 50; i++){
			vvi _M = M;
			shuffle(_M.begin(), _M.end(), rng);
			mapping.push_back(_M);
		}
	}
}

ll Bruno(int N, int A[]){
	generate();

	ll answer = 0;
	for (int i = N-3; i >= 0; i -= 3){
		vector<int> S(3);
		iota(S.begin(), S.end(), i);

		int repr = 0;
		for (int j = 0; j < 3; j++){
			repr += (A[S[j]] << j);
		}

		int value = -1;
		for (int j = 0; j < 4; j++){
			for (auto k: mapping[i/3][j]){
				if (repr == k) value = j;
			}
		}

		if (value >= 0) answer = (answer << 2) + value;
	}

	// cout << "Bruno: " << answer << "\n";
	return answer;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2428 KB Output is correct - L* = 40
2 Correct 28 ms 2432 KB Output is correct - L* = 40
3 Correct 28 ms 2424 KB Output is correct - L* = 40
4 Correct 28 ms 2488 KB Output is correct - L* = 40
5 Correct 31 ms 2352 KB Output is correct - L* = 40
6 Correct 28 ms 2424 KB Output is correct - L* = 40
7 Correct 27 ms 2452 KB Output is correct - L* = 40
8 Correct 28 ms 2488 KB Output is correct - L* = 40
9 Correct 29 ms 2392 KB Output is correct - L* = 40
10 Correct 28 ms 2444 KB Output is correct - L* = 40
11 Correct 28 ms 2504 KB Output is correct - L* = 40
12 Correct 30 ms 2452 KB Output is correct - L* = 40
13 Correct 32 ms 2532 KB Output is correct - L* = 40
14 Correct 28 ms 2392 KB Output is correct - L* = 40
15 Correct 33 ms 2404 KB Output is correct - L* = 40
16 Correct 28 ms 2376 KB Output is correct - L* = 40
17 Correct 27 ms 2500 KB Output is correct - L* = 40
18 Correct 28 ms 2496 KB Output is correct - L* = 40
19 Correct 28 ms 2408 KB Output is correct - L* = 40
20 Correct 28 ms 2424 KB Output is correct - L* = 40
21 Correct 27 ms 2512 KB Output is correct - L* = 40
22 Correct 28 ms 2440 KB Output is correct - L* = 40
23 Correct 29 ms 2496 KB Output is correct - L* = 40
24 Correct 30 ms 2496 KB Output is correct - L* = 40
25 Correct 29 ms 2452 KB Output is correct - L* = 40
26 Correct 29 ms 2424 KB Output is correct - L* = 40
27 Correct 29 ms 2476 KB Output is correct - L* = 40
28 Correct 29 ms 2360 KB Output is correct - L* = 40
29 Correct 28 ms 2476 KB Output is correct - L* = 40
30 Correct 28 ms 2496 KB Output is correct - L* = 40
31 Correct 28 ms 2356 KB Output is correct - L* = 40
32 Correct 28 ms 2500 KB Output is correct - L* = 40
33 Correct 29 ms 2412 KB Output is correct - L* = 40
34 Correct 30 ms 2480 KB Output is correct - L* = 40
35 Correct 30 ms 2436 KB Output is correct - L* = 40
36 Correct 29 ms 2384 KB Output is correct - L* = 40
37 Correct 28 ms 2388 KB Output is correct - L* = 40
38 Correct 33 ms 2372 KB Output is correct - L* = 40
39 Correct 28 ms 2480 KB Output is correct - L* = 40
40 Correct 28 ms 2356 KB Output is correct - L* = 40