Submission #525655

# Submission time Handle Problem Language Result Execution time Memory
525655 2022-02-12T10:21:26 Z prvocislo Aliens (IOI07_aliens) C++17
20 / 100
4 ms 200 KB
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <chrono>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <queue>
#include <bitset>
#include <cmath>
#include <cassert>
typedef long long ll;
typedef long double ld;
using namespace std;

const int logn = 31;
int n, xo, yo;
vector<vector<int> > h;
bool query(int i, int num)
{
	int x, y;
	if (num == 0) x = i, y = yo;
	if (num == 1) x = xo, y = i;
	if (x < 1 || y < 1 || x > n || y > n) return false;
	cout << "examine " << x << " " << y << endl;
	//return h[x][y];
	string s;
	cin >> s;
	return s == "true";
}
int find_last(int l, int r, int good, int num) // najdeme posledne policko, ktore ma farbu l
{
	while (l < r)
	{
		int m = (l + r + 1) / 2;
		if (query(m, num) == good) 
			l = m;
		else 
			r = m - 1;
	}
	return l;
}
int find_one(int i0, int num)
{
	int lw = i0, rw = i0;
	for (int b = 0; b < logn; b++)
	{
		int i = i0 - min(1 << b, i0);
		if (lw == i0 && !query(i, num)) lw = i;
		i = i0 + min(1 << b, n + 1 - i0);
		if (rw == i0 && !query(i, num)) rw = i;
	}
	if (lw == i0) lw = 0;
	if (rw == i0) rw = n + 1;
	int lb = find_last(lw, i0, 0, num) + 1;
	int rb = find_last(i0, rw, 1, num);
	int k = rb - lb + 1;
	int first = lb;
	while (query(first - 2 * k, num)) first -= 2 * k;
	return first + (5 * k) / 2;
}
int main()
{
	cin >> n >> xo >> yo;
	//h.assign(n + 1, vector<int>(n + 1));
	//for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> h[i + 1][j + 1];
	int xc = find_one(xo, 0);
	int yc = find_one(yo, 1);
	cout << "solution " << xc << " " << yc << endl;
	return 0;
}

Compilation message

aliens.cpp: In function 'bool query(int, int)':
aliens.cpp:24:9: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |  int x, y;
      |         ^
aliens.cpp:24:6: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |  int x, y;
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 1 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Runtime error 3 ms 200 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 200 KB Output is correct
2 Runtime error 4 ms 200 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -