#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;
vector<int> adj[1005];
int likes[1005];
int answered[1005];
void addedge(int u, int v){
//show2(u,v);
adj[u].push_back(v);
adj[v].push_back(u);
}
void answer(int u, int v){
//show3("ANS", u, v);
answered[u] = 1;
answered[v] = 1;
Answer(u,v);
}
void Solve(int n){
for(int i = 1;i <= 2*n;i++){
for(int j = i+1;j <= 2*n;j++){
int res = Query({i,j});
if(res == 1) addedge(i,j);
}
}
///the last stuff;
for(int i = 1;i <= 2*n;i++){
if(answered[i]) continue;
if(sz(adj[i]) == 1){
answer(i, adj[i][0]);
//show2(i, adj[i][0]);
}
else if(sz(adj[i]) == 3){
vector<int> &v = adj[i];
if(Query({i,v[0],v[1]}) == 1) likes[i] = v[2];
if(Query({i,v[2],v[1]}) == 1) likes[i] = v[0];
if(Query({i,v[0],v[2]}) == 1) likes[i] = v[1];
//show2(i, likes[i]);
}
else assert(false);
}
for(int i = 1;i <= 2*n;i++){
if(answered[i]) continue;
for(int x : adj[i]){
if(likes[x] != i and likes[i] != x) answer(i,x);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
24 ms |
200 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
0 ms |
328 KB |
Output is correct |
8 |
Incorrect |
0 ms |
328 KB |
Wrong Answer [5] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
0 ms |
328 KB |
Output is correct |
8 |
Incorrect |
0 ms |
328 KB |
Wrong Answer [5] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
24 ms |
332 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 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
24 ms |
200 KB |
Wrong Answer [3] |
4 |
Halted |
0 ms |
0 KB |
- |