Submission #245204

# Submission time Handle Problem Language Result Execution time Memory
245204 2020-07-05T17:37:12 Z kostia244 Chameleon's Love (JOI20_chameleon) C++17
4 / 100
3000 ms 432 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
bool add(vector<int> x, vector<int> v) {
	for(auto i : v) x.push_back(i);
	return Query(x) == x.size();
}
vector<int> seg(vector<int> v, int l, int r) {
	vector<int> res;
	while(l <= r) res.push_back(v[l++]);
	return res;
}
vector<int> pref(vector<int> v, int x) {
	return seg(v, 0, x);
}
void Solve(int n) {
	vector<vi> g(2*n+1);
	vi l, r;
	for(int i = 1; i <= 2*n; i++) (add(l, {i}) ? l : r).push_back(i);
	while(l.size() != n);
	vector<int> c;
	for(int i = 0; i < n; i++) {
		int f = 0;
		while(!add({l[i]}, seg(r, f, n-1))) {
			for(int z = 1<<9; z>>=1;)
				if(f+z < n && add(pref(r, f+z), {l[i]})) f += z;
			f += Query({l[i], r[f]}) == 2;
			g[r[f]].push_back(l[i]);
			g[l[i]].push_back(r[f]);
			f++;
		}
	}
	set<pair<int, int>> bad;
	for(int i = 1; i <= 2*n; i++) {
		if(g[i].size() == 1) continue;
		if(Query({g[i][0], g[i][1], i}) == 1) bad.insert(minmax(g[i][2], i));
		if(Query({g[i][0], g[i][2], i}) == 1) bad.insert(minmax(g[i][1], i));
		if(Query({g[i][2], g[i][1], i}) == 1) bad.insert(minmax(g[i][0], i));
	}
	for(int i = 1; i <= 2*n; i++) {
		while(bad.count(minmax(i, g[i].back()))) g[i].pop_back();
		if(i < g[i].back())
		Answer(i, g[i].back());
	}
}

Compilation message

chameleon.cpp: In function 'bool add(std::vector<int>, std::vector<int>)':
chameleon.cpp:7:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  return Query(x) == x.size();
         ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(l.size() != n);
        ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 43 ms 384 KB Output is correct
4 Correct 43 ms 384 KB Output is correct
5 Correct 43 ms 384 KB Output is correct
6 Correct 42 ms 432 KB Output is correct
7 Correct 48 ms 384 KB Output is correct
8 Correct 43 ms 384 KB Output is correct
9 Correct 44 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 288 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Execution timed out 3090 ms 384 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 288 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Execution timed out 3090 ms 384 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 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 105 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 43 ms 384 KB Output is correct
4 Correct 43 ms 384 KB Output is correct
5 Correct 43 ms 384 KB Output is correct
6 Correct 42 ms 432 KB Output is correct
7 Correct 48 ms 384 KB Output is correct
8 Correct 43 ms 384 KB Output is correct
9 Correct 44 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 288 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Execution timed out 3090 ms 384 KB Time limit exceeded
14 Halted 0 ms 0 KB -