답안 #1107646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107646 2024-11-01T19:32:04 Z andrei_c1 마술쇼 (APIO24_show) C++17
0 / 100
3 ms 1060 KB
#include "Alice.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<pair<int, int>> Alice() {
	const int kBits = 60;
	const int kBuc = 83;
	const int kN = kBits * kBuc + 2;
	const int kSeed = 3141241;
	const int kMod = 1235141242;
	ll x = setN(kN);
	vector<pair<int, int>> edg(kN - 1);
	array<int, kN + 1> ord;
	iota(ord.begin() + 1, ord.end(), 1);
	shuffle(ord.begin() + 1, ord.end(), default_random_engine(kSeed));
	auto addEdge = [&](int idx, int u, int v) -> void {
		edg[idx] = make_pair(ord[u], ord[v]);
	};
	addEdge(0, 1, 2);
	int u = 3;
	mt19937 rng(kSeed);
	auto addBit = [&](int i) -> void {
		bool b = x >> i & 1ll;
		for(int _ = 0; _ < kBuc; _++) {
			int rval = rng() % kMod;
			addEdge(_ * kBits + i + 1, u, (rval + b) % (u - 1) + 1);
			u++;
		}
	};
	for(int i = 0; i < kBits; i++) {
		addBit(i);
	}
	return edg;
}
#include "Bob.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll Bob(vector<pair<int, int>> edg){
	const int kBits = 60;
	const int kBuc = 83;
	const int kN = kBits * kBuc + 2;
	const int kSeed = 3141241;
	const int kMod = 1235141242;
	sort(edg.begin(), edg.end());
	array<int, kN + 1> ord;
	iota(ord.begin() + 1, ord.end(), 1);
	shuffle(ord.begin() + 1, ord.end(), default_random_engine(kSeed));
	auto contains = [&](int u, int v) -> bool {
		return binary_search(edg.begin(), edg.end(), make_pair(ord[u], ord[v]));
	};
	int u = 3;
	ll x = 0;
	mt19937 rng(kSeed);
	auto findBit = [&]() -> ll {
		ll res = -1;
		for(int _ = 0; _ < kBuc; _++) {
			int rval = rng() % kMod;
			for(bool b : {false, true}) {
				if(contains(u, (rval + b) % (u - 1) + 1)) {
					res = b;
				}
			}
			u++;
		}
		assert(res != -1);
		return res;
	};
	for(int i = 0; i < kBits; i++) {
		x |= findBit() << i;
	}
	return x;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 820 KB Correct.
2 Runtime error 2 ms 1060 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 820 KB Correct.
2 Runtime error 2 ms 1060 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 820 KB Correct.
2 Runtime error 2 ms 1060 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -