답안 #83406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83406 2018-11-07T13:45:05 Z Tusk Aliens (IOI07_aliens) C++14
100 / 100
4 ms 560 KB
#include <bits/stdc++.h>

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

using namespace std;

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

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

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

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

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

        long 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;

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

        return 0;
}

Compilation message

aliens.cpp: In function 'bool get(long long int, long long int)':
aliens.cpp:20: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:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld", &n, &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 404 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 3 ms 548 KB Output is correct
3 Correct 3 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 552 KB Output is correct
2 Correct 4 ms 560 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 560 KB Output is correct
2 Correct 2 ms 560 KB Output is correct
3 Correct 3 ms 560 KB Output is correct