#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> g[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 Solve(int N) {
n = N;
for (int i = 1; i <= n * 2; i++) {
if (found[i]) {
continue;
}
vector <int> cand;
for (int j = 1; j <= n * 2; j++) {
if (i != j) {
vector <int> ask = {i, j};
if (Query(ask) == 1) {
cand.pb(j);
}
}
}
if (szof(cand) == 1) {
Answer(i, cand[0]);
found[i] = found[cand[0]] = 1;
}
else {
assert(szof(cand) == 3);
for (int to : cand) {
g[i].pb(to);
}
}
}
for (int i = 1; i <= n * 2; i++) {
for (int j = i + 1; j <= n * 2; j++) {
if (exist(g[i], j) && exist(g[j], i)) {
G[i].pb(j);
G[j].pb(i);
}
}
}
for (int i = 1; i <= n * 2; i++) {
if (!found[i]) {
set <int> cand;
assert(szof(g[i]) == 3);
for (int el : g[i]) {
cand.insert(el);
}
assert(szof(G[i]) == 2);
for (int el : G[i]) {
cand.erase(el);
}
int need = *cand.begin();
found[i] = found[need] = 1;
Answer(i, need);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
21 ms |
328 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 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 |
1 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 |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
21 ms |
328 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |