답안 #245205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
245205 2020-07-05T17:37:47 Z kostia244 카멜레온의 사랑 (JOI20_chameleon) C++17
0 / 100
107 ms 384 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++) (i <= n ? 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();
         ~~~~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 107 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 105 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 107 ms 384 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -