Submission #24690

# Submission time Handle Problem Language Result Execution time Memory
24690 2017-06-11T21:29:42 Z Bruteforceman ICC (CEOI16_icc) C++11
0 / 100
3 ms 2220 KB
// #define LOCAL

#include "bits/stdc++.h"
#ifndef LOCAL
#include "icc.h"
#endif

using namespace std;

#ifdef LOCAL
int query(int size_a, int size_b, int a[], int b[]) {
	cout << "set A: ";
	for(int i = 0; i < size_a; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
	cout << "set B: ";
	for(int i = 0; i < size_b; i++) {
		cout << b[i] << " ";
	}
	cout << endl;
	int x;
	cin >> x;
 	return x;
}
void setRoad(int a, int b) {
	cout << "join " << a << " and " << b << endl;
}
#endif

int ask(vector <int> p, vector <int> q) {
	int size_a = p.size();
	int size_b = q.size();
	if(size_a == 0 || size_b == 0) return 0;
	int *a, *b;
	a = new int [size_a];
	b = new int [size_b];
	for(int j = 0; j < size_a; j++) {
		a[j] = p[j];
	}
	for(int j = 0; j < size_b; j++) {
		b[j] = q[j];
	}
	return query(size_a, size_b, a, b);
}

int n;
vector <int> setA, setB;
int search(int b, int e) {
	if(b == e) {
		return setB[b];
	}
	int m = (b + e) >> 1;
	vector <int> v;
	for(int i = b; i <= m; i++) {
		v.push_back(setB[i]);
	}
	if(ask(setA, v)) return search(b, m);
	else return search(m + 1, e);
}
void find_road() {
	int xor_val = 0;
	for(int i = 0; i < 7; i++) {
		int size_a = 0;
		int size_b = 0;
		vector <int> p, q;
		for(int j = 1; j <= n; j++) {
			if((j >> i) & 1) q.push_back(j);
			else p.push_back(j); 
		}
		if(ask(p, q)) {
			setA = p;
			setB = q;
			xor_val |= 1 << i;
		}
	}
	int node1 = search(0, setB.size() - 1);
	int node2 = node1 ^ xor_val;
	setRoad(node1, node2);
}

void run(int N) {
	n = N;
	for(int i = 1; i < n; i++) {
		find_road();
	}
}

#ifdef LOCAL
int main(int argc, char const *argv[])
{
	run(6);
	return 0;
}
#endif

Compilation message

icc.cpp: In function 'void find_road()':
icc.cpp:65:7: warning: unused variable 'size_a' [-Wunused-variable]
   int size_a = 0;
       ^
icc.cpp:66:7: warning: unused variable 'size_b' [-Wunused-variable]
   int size_b = 0;
       ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2084 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2080 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2220 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2216 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2216 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2216 KB Wrong road!
2 Halted 0 ms 0 KB -