Submission #64763

# Submission time Handle Problem Language Result Execution time Memory
64763 2018-08-05T14:48:05 Z aome Aliens (IOI07_aliens) C++17
0 / 100
1000 ms 548 KB
#include <bits/stdc++.h>

using namespace std;

int n, m;
int x, y;
int xc, yc;
int cnt;
bool a[105][105];
char rep[10];

bool ask(int i, int j) {
	if (i < 1 || i > n || j < 1 || j > n) return 0;
	printf("examine %d %d\n", i, j);
	fflush(stdout);
	scanf("%s", &rep); return rep[0] == 't';
	// ++cnt;
	// return a[i][j];
}

void local() {
	srand(time(0));
	n = 100;
	m = rand() % ((n - 5) / 10 + 1);
	m = m * 2 + 1;
	assert(m * 5 <= n);
	int l = 1 + 5 * m / 2;
	int r = n - 5 * m / 2;
	assert(l <= r);
	xc = rand() % (r - l + 1) + l;
	yc = rand() % (r - l + 1) + l;
	vector< pair<int, int> > cand;
	for (int i = -2; i <= 2; ++i) {
		for (int j = -2; j <= 2; ++j) {
			if (abs(i - j) % 2) continue;
			int xt = xc + i * m, yt = yc + j * m;
			for (int k = -m / 2; k <= m / 2; ++k) {
				for (int l = -m / 2; l <= m / 2; ++l) {
					a[xt + k][yt + l] = 1;
					cand.push_back({xt + k, yt + l});
				}
			}
		}
	}
	int id = rand() % (int)cand.size();
	x = cand[id].first, y = cand[id].second;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			cout << a[i][j];
		}
		cout << '\n';
	}
	cout << x << ' ' << y << '\n';
}

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};

int main() {
	// local();
	scanf("%d %d %d", &n, &x, &y);
	int lx, rx, ly, ry;
	for (int i = 0; i < 4; ++i) {
		int cur;
		if (i == 0) cur = x - 1;
		if (i == 1) cur = n - x;
		if (i == 2) cur = y - 1;
		if (i == 3) cur = n - y;
		while (1) {
			int l = 0, r = cur;
			while (l < r) {
				int mid = (l + r + 1) >> 1;
				if (ask(x + dx[i] * mid, y + dy[i] * mid)) l = mid; else r = mid - 1;
			}
			if (l == cur) break;
			cur = l;
		}
		if (i == 0) lx = x - cur;
		if (i == 1) rx = x + cur;
		if (i == 2) ly = y - cur;
		if (i == 3) ry = y + cur;
	}
	// cout << lx << ' ' << rx << ' ' << ly << ' ' << ry << '\n';
	int xt = (lx + rx) / 2, yt = (ly + ry) / 2;
	int plx = 0, prx = 0;
	int ply = 0, pry = 0;
	while (ask(xt + (plx - 2) * m, yt)) plx -= 2;
	while (ask(xt + (prx + 2) * m, yt)) prx += 2;
	while (ask(xt, yt + (ply - 2) * m)) ply -= 2;
	while (ask(xt, yt + (pry + 2) * m)) pry += 2;
	int xr = xt + (plx + prx) * m / 2;
	int yr = yt + (ply + pry) * m / 2;
	// assert(xr == xc && yr == yc);
	printf("solution %d %d\n", xr, yr);
	fflush(stdout);
	// cout << xr << ' ' << yr << '\n';
	// cout << xc << ' ' << yc << '\n';
	// cout << cnt << '\n';
}

Compilation message

aliens.cpp: In function 'bool ask(int, int)':
aliens.cpp:16:18: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[10]' [-Wformat=]
  scanf("%s", &rep); return rep[0] == 't';
              ~~~~^
aliens.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", &rep); return rep[0] == 't';
  ~~~~~^~~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &x, &y);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp:84:35: warning: 'ry' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int xt = (lx + rx) / 2, yt = (ly + ry) / 2;
                               ~~~~^~~~~
aliens.cpp:84:35: warning: 'ly' may be used uninitialized in this function [-Wmaybe-uninitialized]
aliens.cpp:84:15: warning: 'rx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int xt = (lx + rx) / 2, yt = (ly + ry) / 2;
           ~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1053 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1048 ms 492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 548 KB Time limit exceeded
2 Halted 0 ms 0 KB -