#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);
}
void Solve(int N) {
n = N;
for (int i = 1; i <= n * 2; i++) {
if (found[i]) {
continue;
}
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) {
Answer(i, cand[i][0]);
found[i] = found[cand[i][0]] = 1;
}
else {
for (int to : cand[i]) {
g[i].pb(to);
}
}
}
for (int i = 1; i <= n * 2; i++) {
if (found[i]) {
continue;
}
assert(szof(cand[i]) == 3);
int a = cand[i][0];
int b = cand[i][1];
int c = cand[i][2];
bool ok = 0;
if (Query({i, a, b}) == 1) {
ok = 1;
make_edge(i, c);
}
else if (Query({i, a, c}) == 1) {
ok = 1;
make_edge(i, b);
} else {
ok = 1;
make_edge(i, c);
}
assert(ok);
}
for (int i = 1; i <= n * 2; i++) {
if (found[i]) {
continue;
}
set <int> st;
for (int el : cand[i]) {
st.insert(el);
}
assert(szof(st) == 3);
assert(szof(g[i]) == 2);
for (int to : g[i]) {
st.erase(to);
}
int need = *st.begin();
Answer(i, need);
found[i] = found[need] = 1;
}
}
// lol
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Incorrect |
20 ms |
456 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Incorrect |
20 ms |
456 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |