Submission #444750

# Submission time Handle Problem Language Result Execution time Memory
444750 2021-07-15T05:39:48 Z ics0503 Chameleon's Love (JOI20_chameleon) C++17
24 / 100
41 ms 356 KB
#include "chameleon.h"
#include <vector>
using namespace std;

int cck[1212];
void validation(int n, int i, int j) {
	vector<int>qr;
	for (int p = 1; p <= 2 * n; p++) {
		if (i == p || j == p)continue;
		qr.push_back(p);
	}
	int Q = Query(qr);
	if (Q != n) {
		cck[i] = cck[j] = 1;
		Answer(i, j);
	}
}

void S4(int who, vector<int>Y, int n) {
	int sz = Y.size(), i, j;
	if (sz == 1) {
		validation(n, who, Y[0]);
		return;
	}
	vector<int>L, R;
	for (i = 0; i < sz / 2; i++)L.push_back(Y[i]);
	for (i = sz / 2; i < sz; i++)R.push_back(Y[i]);
	L.push_back(who); R.push_back(who);
	int a = Query(L); int b = Query(R);
	L.pop_back(); R.pop_back();
	if (a != L.size() + 1)S4(who, L, n);
	if (b != R.size() + 1)S4(who, R, n);
}


vector<int>AX, AY;
int pk[1212];
void Solve(int n) {
	int i, j;
	while (1) {
		vector<int>X;
		for (i = 1; i <= 2 * n; i++)pk[i] = 0;
		int cnt = 0;
		for (i = 1; i <= 2 * n; i++) {
			if (cck[i])continue;
			cnt++;
			X.push_back(i);
			if (Query(X) != X.size()) {
				X.pop_back();
			}
			else {
				pk[i] = 1;
			}
		}
		if (cnt == 0)break;
		
		for (i = 1; i <= 2 * n; i++) {
			if (cck[i])continue;
			if (pk[i])AX.push_back(i);
			else AY.push_back(i);
		}
		for (i = 0; i < AX.size(); i++) {
			int who = AX[i];
			vector<int>Y;
			for (j = 0; j < AY.size(); j++) {
				int v = AY[j];
				if (cck[v])continue;
				Y.push_back(v);
			}
			S4(who, Y, n);
		}
	}
}

Compilation message

chameleon.cpp: In function 'void S4(int, std::vector<int>, int)':
chameleon.cpp:31:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  if (a != L.size() + 1)S4(who, L, n);
      |      ~~^~~~~~~~~~~~~~~
chameleon.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  if (b != R.size() + 1)S4(who, R, n);
      |      ~~^~~~~~~~~~~~~~~
chameleon.cpp:20:24: warning: unused variable 'j' [-Wunused-variable]
   20 |  int sz = Y.size(), i, j;
      |                        ^
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:48:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |    if (Query(X) != X.size()) {
      |        ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:62:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   for (i = 0; i < AX.size(); i++) {
      |               ~~^~~~~~~~~~~
chameleon.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    for (j = 0; j < AY.size(); j++) {
      |                ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 25 ms 328 KB Output is correct
4 Correct 25 ms 356 KB Output is correct
5 Correct 25 ms 340 KB Output is correct
6 Correct 25 ms 332 KB Output is correct
7 Correct 25 ms 352 KB Output is correct
8 Correct 27 ms 352 KB Output is correct
9 Correct 27 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Incorrect 0 ms 200 KB Wrong Answer [2]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Incorrect 0 ms 200 KB Wrong Answer [2]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 39 ms 332 KB Output is correct
4 Correct 39 ms 336 KB Output is correct
5 Correct 41 ms 332 KB Output is correct
6 Correct 38 ms 348 KB Output is correct
7 Correct 39 ms 328 KB Output is correct
8 Correct 40 ms 336 KB Output is correct
9 Correct 39 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 25 ms 328 KB Output is correct
4 Correct 25 ms 356 KB Output is correct
5 Correct 25 ms 340 KB Output is correct
6 Correct 25 ms 332 KB Output is correct
7 Correct 25 ms 352 KB Output is correct
8 Correct 27 ms 352 KB Output is correct
9 Correct 27 ms 304 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 0 ms 200 KB Output is correct
12 Correct 0 ms 200 KB Output is correct
13 Incorrect 0 ms 200 KB Wrong Answer [2]
14 Halted 0 ms 0 KB -