Submission #79135

# Submission time Handle Problem Language Result Execution time Memory
79135 2018-10-11T11:47:55 Z Sherazin Aliens (IOI07_aliens) C++14
80 / 100
4 ms 680 KB
#include <bits/stdc++.h>

#define pii pair<int, int>
#define x first
#define y second

using namespace std;

int n, a, b, m;
map<pii, int> mp;

void print(const char *c, int x, int y) { printf(c, x, y), fflush(stdout); }

bool get(int x, int y) {
	if(x < 1 || x > n || y < 1 || y > n) return false;
	if(!mp.count(pii(x, y))) {
		char s[10];
		print("examine %d %d\n", x, y);
		scanf(" %s", s);
		mp[pii(x, y)] = (s[0] == 't');
	}
	return mp[pii(x, y)];
}

int find(int x, int y, int dx, int dy) {
	int d = 1;
	while(get(x + dx*d, y + dy*d)) d <<= 1;
	int l = d >> 1, r = d;
	while(l < r) {
		int m = (l + r + 1) >> 1;
		if(get(a + dx*m, b + dy*m)) l = m;
		else r = m-1;
	}
	return l;
}

int main() {
	scanf("%d %d %d", &n, &a, &b);
	int left = find(a, b, -1, 0), right = find(a, b, 1, 0);
	int up = find(a, b, 0, 1), down = find(a, b, 0, -1);
        m = right + left + 1;
        assert(right + left == up + down);

    	int xm = (2*a + right - left) / 2, ym = (2*b + up - down) / 2;

        while(get(xm - 2*m, ym)) xm -= 2*m;
        while(get(xm, ym - 2*m)) ym -= 2*m;
        while(get(xm - m, ym - m)) xm -= m, ym -= m;

        int ax = xm + m*2, ay = ym + m*2;
        print("solution %d %d\n", ax, ay);

	return 0;
}

Compilation message

aliens.cpp: In function 'bool get(int, int)':
aliens.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %s", s);
   ~~~~~^~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 408 KB Output is correct
2 Correct 2 ms 412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 436 KB Output is correct
2 Correct 3 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 452 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 500 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 552 KB Output is correct
2 Correct 3 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 552 KB Output is correct
2 Correct 2 ms 552 KB Output is correct
3 Correct 3 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 552 KB Output is correct
2 Correct 3 ms 552 KB Output is correct
3 Correct 3 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 680 KB Output is correct
2 Incorrect 3 ms 680 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 680 KB Output is correct
2 Incorrect 4 ms 680 KB Incorrect
3 Halted 0 ms 0 KB -