Submission #424091

# Submission time Handle Problem Language Result Execution time Memory
424091 2021-06-11T16:32:19 Z milleniumEeee Chameleon's Love (JOI20_chameleon) C++17
0 / 100
25 ms 352 KB
#ifndef EVAL
#include "grader.cpp"
#endif
#include "chameleon.h"
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ll long long
using namespace std;

const int MAXN = 505;

// Query(p) | p is vector<int>
// Answer(a, b)

int n;

bool found[MAXN * 2];

vector <int> cand[MAXN * 2];
vector <int> g[MAXN * 2];

bool exist(vector <int> &vec, int x) {
	for (int el : vec) {
		if (el == x) {
			return true;
		}
	}
	return false;
}

void make_edge(int x, int y) {
	g[x].pb(y);
	g[y].pb(x);
}

pii get_para(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	return {x, y};
}

int ans[MAXN * 2];
bool f[MAXN * 2][MAXN * 2];

void Solve(int N) {
	n = N;
	// creating tree
	set <pii> cyc;
	for (int i = 1; i <= n * 2; i++) {
		for (int j = 1; j <= n * 2; j++) {
			if (i != j) {
				vector <int> ask = {i, j};
				if (Query(ask) == 1) {
					cand[i].pb(j);
				}
			}
		}
		if (szof(cand[i]) == 1) {
			int x = i, y = cand[i][0];
			ans[x] = y;
			ans[y] = x;
		}
	}
	for (int i = 1; i <= n * 2; i++) {
		if (!ans[i]) {
			int a = cand[i][0];
			int b = cand[i][1];
			int c = cand[i][2];
			if (Query({i, a, b})) {
				f[i][c] = f[c][i] = 1;
			}
			else if (Query({i, a, c})) {
				f[i][b] = f[b][i] = 1;
			}
			else {
				f[i][c] = f[c][i] = 1;
			}
		}
	}
	for (int i = 1; i <= n * 2; i++) {
		if (!ans[i]) {
			set <int> st;
			for (int el : cand[i]) {
				st.insert(el);
			}
			for (int j = 1; j <= n * 2; j++) {
				if (f[i][j]) {
					st.erase(j);
				}
			}
			int need = *st.begin();
			ans[i] = need;
			ans[need] = i;
		}
	}
	set <pii> omg;
	for (int i = 1; i <= n * 2; i++) {
		omg.insert(get_para(i, ans[i]));
	}
	for (auto [x, y] : omg) {
		Answer(x, y);
	}
}
/*
3
0 0 0 1 1 1
3 1 3 2 2 1
4 5 6 3 2 1
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Incorrect 25 ms 352 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Incorrect 0 ms 328 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Incorrect 0 ms 328 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Incorrect 0 ms 328 KB Wrong Answer [4]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Incorrect 25 ms 352 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -