Submission #423683

# Submission time Handle Problem Language Result Execution time Memory
423683 2021-06-11T11:19:13 Z oolimry Chameleon's Love (JOI20_chameleon) C++17
40 / 100
32 ms 332 KB
#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);
	if(answered[u] or answered[v]) return;
	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 0 ms 328 KB Output is correct
3 Incorrect 24 ms 328 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 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
# 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 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 2 ms 328 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 2 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 2 ms 328 KB Output is correct
17 Correct 2 ms 328 KB Output is correct
18 Correct 2 ms 328 KB Output is correct
# 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 32 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 0 ms 328 KB Output is correct
3 Incorrect 24 ms 328 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -