답안 #245203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
245203 2020-07-05T17:36:16 Z kostia244 카멜레온의 사랑 (JOI20_chameleon) C++17
4 / 100
106 ms 640 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);
	assert(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();
         ~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from chameleon.cpp:2:
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:21:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  assert(l.size() == n);
         ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 42 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 45 ms 384 KB Output is correct
7 Correct 44 ms 504 KB Output is correct
8 Correct 42 ms 384 KB Output is correct
9 Correct 47 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 106 ms 384 KB Wrong Answer [3]
4 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 Correct 42 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 45 ms 384 KB Output is correct
7 Correct 44 ms 504 KB Output is correct
8 Correct 42 ms 384 KB Output is correct
9 Correct 47 ms 512 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Halted 0 ms 0 KB -