Submission #229493

# Submission time Handle Problem Language Result Execution time Memory
229493 2020-05-04T19:23:40 Z wilwxk Chameleon's Love (JOI20_chameleon) C++14
40 / 100
21 ms 420 KB
#include <bits/stdc++.h>
#include "chameleon.h"
using namespace std;

const int MAXN = 505;
vector<int> g[MAXN], g2[MAXN];
bool marc[MAXN];
int n;

void Solve(int N) {
	n = 2*N;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < i; j++) {
			if(Query({i, j}) == 1) {
				g[i].push_back(j);
				g[j].push_back(i);
				// printf("%d - %d\n", i, j);
			}
		}
	}


	for(int i = 1; i <= n; i++) {
		if(g[i].size() == 1) {
			// printf("bleh %d %d\n", i, g[i][0]);
			if(!marc[i]) Answer(i, g[i][0]);
			marc[i] = marc[g[i][0]] = 1;
		}
		else {
			int v;
			if(Query({i, g[i][0], g[i][1]}) == 1) v = g[i][2];
			else if(Query({i, g[i][2], g[i][1]}) == 1) v = g[i][0];
			else if(Query({i, g[i][0], g[i][2]}) == 1) v = g[i][1];
			g2[i].push_back(v);
			g2[v].push_back(i);
		}
	}

	for(int i = 1; i <= n; i++) {
		if(marc[i]) continue;
		int v;
		if(g[i][0] != g2[i][0] && g[i][0] != g2[i][1]) v = g[i][0];
		else if(g[i][1] != g2[i][0] && g[i][1] != g2[i][1])  v = g[i][1];
		else if(g[i][2] != g2[i][0] && g[i][2] != g2[i][1])  v = g[i][2];
		marc[i] = marc[v] = 1;
		// printf("bleh %d %d\n", i, v);
		Answer(i, v);
	}

}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:47:9: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   Answer(i, v);
   ~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 21 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 420 KB Output is correct
13 Correct 6 ms 416 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 21 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 21 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -