Submission #444746

#TimeUsernameProblemLanguageResultExecution timeMemory
444746ics0503Chameleon's Love (JOI20_chameleon)C++17
60 / 100
42 ms452 KiB
#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);
}


void Solve(int n) {
	if (n <= 50) {

		int i, j;
		for (i = 1; i <= 2 * n; i++) {
			for (j = i + 1; j <= 2 * n; 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);
				qr.clear();
				qr.push_back(i);
				qr.push_back(j);
				int P = Query(qr);
				if (Q != n && P == 1) {
					Answer(i, j);
					break;
				}
			}
		}
		return;
	}
	int i, j;
	for (i = 1; i <= n; i++) {
		vector<int>Y;
		for (j = n + 1; j <= n + n; j++) {
			if (cck[j])continue;
			Y.push_back(j);
		}
		S4(i, Y, n);
	}
}

Compilation message (stderr)

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;
      |                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...