Submission #712032

# Submission time Handle Problem Language Result Execution time Memory
712032 2023-03-18T02:04:49 Z LittleCube Chameleon's Love (JOI20_chameleon) C++14
44 / 100
36 ms 464 KB
#include "chameleon.h"
#include <vector>
using namespace std;


vector<int> A, B, E[1005];
int color[1005];
vector<int> adj;

void find(int u, vector<int> v)
{
	if(v.empty())
		return;
	v.emplace_back(u);
   	if(Query(v) == v.size())
		return;
	v.pop_back();
	if(v.size() == 1)
		adj.emplace_back(v[0]);
	else
	{
		int mid = v.size() / 2;
		vector<int> l(v.begin(), v.begin() + mid), r(v.begin() + mid, v.end());
		find(u, l);
		find(u, r);
	}
}

void dfs(int u)
{
	for (auto v : E[u])
		if(!color[v])
		{
			color[v] = 3 ^ color[u];
			dfs(v);
		}
}

void Solve(int N)
{
	for (int i = 1; i <= 2 * N; i++)
	{
		for (int j = 1; j < i; j++)
			color[j] = 0;
		for (int j = 1; j < i; j++)
			if(!color[j])
			{
				color[j] = 1;
				dfs(j);
			}
		A.clear(), B.clear();
		for (int j = 1; j < i; j++)
			(color[j] == 1 ? A : B).emplace_back(j);
		adj.clear();
		find(i, A);
		find(i, B);
		for (int j : adj)
		{
			E[i].emplace_back(j);
			E[j].emplace_back(i);
		}
	}
	for (int i = 1; i <= 2 * N; i++)
		if(E[i].size() == 3)
		{
			int a = E[i][0], b = E[i][1], c = E[i][2];
			int x = Query(vector<int>{i, a, b}),
				y = Query(vector<int>{i, b, c}),
				z = Query(vector<int>{i, c, a});
			if(x == 2 && y == 2)
				E[i].emplace_back(-b), E[b].emplace_back(-i);
			if(y == 2 && z == 2)
				E[i].emplace_back(-c), E[c].emplace_back(-i);
			if(z == 2 && x == 2)	
				E[i].emplace_back(-a), E[a].emplace_back(-i);
		}
		else if(E[i].size() == 4)
		{
			int a = E[i][0], b = E[i][1], c = E[i][2];
			int x;
			if(E[i][3] == -a)
				x = (Query(vector<int>{i, a, b}) == 2 ? b : c);
			else if(E[i][3] == -b)
				x = (Query(vector<int>{i, b, c}) == 2 ? c : a);
			else	
				x = (Query(vector<int>{i, c, a}) == 2 ? a : b);
					
			E[i].emplace_back(-x), E[x].emplace_back(-i);
		}
	for (int i = 1; i <= 2 * N; i++)
	{
		int sum = 0;
		for(auto j : E[i])
			sum += j;
		if(i < sum)
			Answer(i, sum);
	}

}

Compilation message

chameleon.cpp: In function 'void find(int, std::vector<int>)':
chameleon.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     if(Query(v) == v.size())
      |        ~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 26 ms 432 KB Output is correct
4 Correct 27 ms 408 KB Output is correct
5 Correct 26 ms 460 KB Output is correct
6 Correct 25 ms 448 KB Output is correct
7 Correct 26 ms 444 KB Output is correct
8 Correct 25 ms 464 KB Output is correct
9 Correct 26 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Incorrect 36 ms 336 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 26 ms 432 KB Output is correct
4 Correct 27 ms 408 KB Output is correct
5 Correct 26 ms 460 KB Output is correct
6 Correct 25 ms 448 KB Output is correct
7 Correct 26 ms 444 KB Output is correct
8 Correct 25 ms 464 KB Output is correct
9 Correct 26 ms 440 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 0 ms 336 KB Output is correct
29 Correct 0 ms 336 KB Output is correct
30 Incorrect 36 ms 336 KB Wrong Answer [3]
31 Halted 0 ms 0 KB -