답안 #883139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883139 2023-12-04T15:58:27 Z NK_ 항공 노선도 (JOI18_airline) C++17
0 / 100
475 ms 46804 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "Alicelib.h"

using namespace std;

#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())

#define f first
#define s second
#define mp make_pair


using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;
using pi = pair<int, int>;
using vpi = V<pi>;

mt19937 rngA(time(nullptr));

vpi ordA(int N) {
	vpi B(10); for(int i = 0; i < 10; i++) {
		B[i] = mp(i, 0);
	}

	for(int i = 0; i < N; i++) {
		for(int b = 0; b < N; b++) if ((i >> b) & 1) B[b].s++;
	}

	shuffle(begin(B), end(B), rngA);

	return B;
}

const int EX = 12;
void Alice(int N, int M, int A[], int B[]){
	int EX1 = N + EX - 2;
	int EX2 = N + EX - 1;


	vpi E;

	for(int i = 0; i < M; i++) {
		E.pb(mp(A[i], B[i]));
	}

	for(int i = 0; i < N; i++) {
		for(int b = 0; b < 10; b++) if ((i >> b) & 1) {
			E.pb(mp(N + b, i));
		}
	}

	vpi ORD = ordA(N);

	// for(auto& x : ORD) cout << "( " << x.f << ", " << x.s << " ) ";
	// cout << endl;

	for(int i = 1; i < sz(ORD); i++) {
		E.pb(mp(ORD[i-1].f + N, ORD[i].f + N));
	}

	E.pb(mp(ORD.back().f + N, EX2));
	E.pb(mp(EX1, EX2));

	for(int i = 0; i < sz(ORD); i++) {
		E.pb(mp(EX1, ORD[i].f + N));
	}

	InitG(N + EX, sz(E));
	for(int i = 0; i < sz(E); i++) {
		// cout << i << " " << E[i].f << " " << E[i].s << endl;
		// if (count(begin(E), end(E), E[i]) > 1) cout << "******" << endl;

		MakeG(i, E[i].f, E[i].s);
	}
}
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "Boblib.h"

using namespace std;

#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())

#define f first
#define s second
#define mp make_pair


using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;
using pi = pair<int, int>;
using vpi = V<pi>;

mt19937 rngB(time(nullptr));

vpi ordB(int N) {
	vpi B(10); for(int i = 0; i < 10; i++) {
		B[i] = mp(i, 0);
	}

	for(int i = 0; i < N; i++) {
		for(int b = 0; b < N; b++) if ((i >> b) & 1) B[b].s++;
	}

	shuffle(begin(B), end(B), rngB);

	return B;
}

const int EX = 12;

void Bob(int N, int M, int A[], int B[]){
	V<vi> adj(N);
	for(int i = 0; i < M; i++) {
		adj[A[i]].pb(B[i]);
		adj[B[i]].pb(A[i]);
	}

	vpi ORD = ordB(N - EX); int K = sz(ORD);
	for(int i = 0; i < K; i++) ORD[i].s += 2 + (i != 0);

	ORD.pb(mp(-1, 2)); K++;

	// for(auto& x : ORD) cout << "( " << x.f << ", " << x.s << " ) ";
	// cout << endl;

	vi stk = {}, alive(N, 0);
	V<vi> vis(N, vi(K + 1));

	V<vi> ans;

	function<void(int, int)> find = [&](int u, int d) {
		// cout << u << " " << d << " => " << sz(adj[u]) << endl;
		stk.pb(u);
		if (d == K) {
			// cout << "FOUND" << endl;
			ans.pb(stk);
		} else {
			for(auto& v : adj[u]) if (alive[v] && count(begin(stk), end(stk), v) == 0) {
				// cout << "E: " << u << " -> " << v << " => " << sz(adj[v]) << " = " << ORD[d].s << " -> " << vis[v][d + 1] << endl;
				// cout << endl;
				if (sz(adj[v]) == ORD[d].s) {
					find(v, d + 1);
				}
			}
		}

		stk.pop_back();
	};

	for(int i = 0; i < N; i++) {
		if (sz(adj[i]) == K) {
			// cout << i << endl;
			vis[i] = vi(K + 1, 0);

			// cout << "ALIVE" << endl;
			for(auto x : adj[i]) {
				// cout << x << " ";
				alive[x] = 1; vis[x] = vi(K + 1, 0);
			}
			// cout << endl;

			find(i, 0);

			for(auto x : adj[i]) alive[x] = 0;
		}
	}

	// for(auto& x : ans) {
	// 	for(auto& v : x) cout << v << " ";
	// 	cout << endl;
	// }

	// assert(sz(ans) > 0);
	// cout << sz(ans) << endl;


	vi BITS(K);	vi X(N); 
	for(auto& x : ans.front()) X[x] = -1;
	for(int i = 1; i < sz(ans.front()) - 1; i++) {
		BITS[ORD[i - 1].f] = ans.front()[i];
		// cout << ORD[i - 1].f << " " << ans.front()[i] << endl;
	}

	// for(auto& x : BITS) cout << x << " ";
	// cout << endl;

	for(int i = 0; i < K-1; i++) {
		for(auto& x : adj[BITS[i]]) {
			if (X[x] == -1) continue;
			X[x] ^= (1 << i);
		}
	}

	vpi E;

	for(int u = 0; u < N; u++) {
		int U = X[u];
		if (U == -1) continue;

		for(auto& v : adj[u]) {
			int V = X[v];
			if (V == -1) continue;

			if (U < V) {
				// cout << U << " " << V << endl;
				E.pb(mp(U, V));
			}
		}
	}

	InitMap(N - EX, sz(E));
	for(int i = 0; i < sz(E); i++) MakeMap(E[i].f, E[i].s);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 15620 KB Output is correct
2 Correct 2 ms 15620 KB Output is correct
3 Correct 2 ms 15616 KB Output is correct
4 Correct 2 ms 13564 KB Output is correct
5 Correct 2 ms 15616 KB Output is correct
6 Correct 2 ms 15612 KB Output is correct
7 Correct 2 ms 15884 KB Output is correct
8 Correct 3 ms 15800 KB Output is correct
9 Correct 3 ms 15620 KB Output is correct
10 Correct 2 ms 13572 KB Output is correct
11 Correct 3 ms 15620 KB Output is correct
12 Correct 2 ms 15620 KB Output is correct
13 Correct 3 ms 15648 KB Output is correct
14 Correct 3 ms 15872 KB Output is correct
15 Correct 3 ms 15616 KB Output is correct
16 Correct 3 ms 15624 KB Output is correct
17 Correct 2 ms 15620 KB Output is correct
18 Correct 2 ms 15616 KB Output is correct
19 Correct 3 ms 15620 KB Output is correct
20 Correct 3 ms 15628 KB Output is correct
21 Correct 3 ms 15616 KB Output is correct
22 Correct 3 ms 15612 KB Output is correct
23 Correct 2 ms 15620 KB Output is correct
24 Correct 2 ms 13572 KB Output is correct
25 Correct 2 ms 15620 KB Output is correct
26 Correct 3 ms 15620 KB Output is correct
27 Correct 2 ms 15620 KB Output is correct
28 Correct 3 ms 15620 KB Output is correct
29 Correct 3 ms 15620 KB Output is correct
30 Runtime error 5 ms 17924 KB Execution killed with signal 11
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 15620 KB Output is correct
2 Correct 2 ms 15620 KB Output is correct
3 Correct 2 ms 15616 KB Output is correct
4 Correct 2 ms 13564 KB Output is correct
5 Correct 2 ms 15616 KB Output is correct
6 Correct 2 ms 15612 KB Output is correct
7 Correct 2 ms 15884 KB Output is correct
8 Correct 3 ms 15800 KB Output is correct
9 Correct 3 ms 15620 KB Output is correct
10 Correct 2 ms 13572 KB Output is correct
11 Correct 3 ms 15620 KB Output is correct
12 Correct 2 ms 15620 KB Output is correct
13 Correct 3 ms 15648 KB Output is correct
14 Correct 3 ms 15872 KB Output is correct
15 Correct 3 ms 15616 KB Output is correct
16 Correct 3 ms 15624 KB Output is correct
17 Correct 2 ms 15620 KB Output is correct
18 Correct 2 ms 15616 KB Output is correct
19 Correct 3 ms 15620 KB Output is correct
20 Correct 3 ms 15628 KB Output is correct
21 Correct 3 ms 15616 KB Output is correct
22 Correct 3 ms 15612 KB Output is correct
23 Correct 2 ms 15620 KB Output is correct
24 Correct 2 ms 13572 KB Output is correct
25 Correct 2 ms 15620 KB Output is correct
26 Correct 3 ms 15620 KB Output is correct
27 Correct 2 ms 15620 KB Output is correct
28 Correct 3 ms 15620 KB Output is correct
29 Correct 3 ms 15620 KB Output is correct
30 Runtime error 5 ms 17924 KB Execution killed with signal 11
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 475 ms 46804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -