Submission #54361

# Submission time Handle Problem Language Result Execution time Memory
54361 2018-07-03T08:35:23 Z 윤교준(#1474) Aliens (IOI07_aliens) C++11
40 / 100
1000 ms 31584 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

unordered_map<ll, bool> MP;

ll L, SX, SY;
ll N, X, Y;

bool ask(ll x, ll y) {
	if(x < 1 || y < 1 || N < x || N < y) return false;
	ll key = x * 2000000001 + y;
	auto it = MP.find(key);
	if(MP.end() != it) return it->second;

	printf("examine %lld %lld\n", x, y);
	fflush(stdout);

	char str[11];
	scanf(" %s", str);
	return (MP[key] = ('t' == str[0]));
}
void answer(ll x, ll y) {
	printf("solution %lld %lld\n", x, y);
	fflush(stdout);
}
void answerLD(ll x, ll y) {
	answer(x + L/2, y + L/2);
}

void findL() {
	{
		ll sx = X, ex = X;
		for(;;) {
			sx--;
			if(!ask(sx, Y)) {
				sx++;
				break;
			}
		}
		for(;;) {
			ex++;
			if(!ask(ex, Y)) {
				ex--;
				break;
			}
		}
		L = ex-sx+1;
		SX = sx;
	}
	{
		for(ll y = Y;;) {
			y--;
			if(!ask(SX, y)) {
				y++;
				SY = y;
				break;
			}
		}
	}
}

void oddprocess() {
	if(ask(SX, SY+L*4)) {
		answerLD(SX, SY+L*2);
		return;
	}
	if(ask(SX, SY-L*4)) {
		answerLD(SX, SY-L*2);
		return;
	}
	answerLD(SX, SY);
}

void evenprocess() {
	if(ask(SX+L, SY+L*3)) {
		answerLD(SX+L, SY+L);
		return;
	}
	answerLD(SX+L, SY-L);
}

void process() {
	if(ask(SX-L*4, SY)) {
		SX = SX - L*2;
		oddprocess();
		return;
	}
	if(ask(SX+L*4, SY)) {
		SX = SX + L*2;
		oddprocess();
		return;
	}
	bool l = ask(SX-L*2, SY), r = ask(SX+L*2, SY);
	if(l && r) {
		oddprocess();
		return;
	}
	if(l) {
		SX = SX-L*2;
		evenprocess();
		return;
	}
	if(r) {
		evenprocess();
		return;
	}
	puts("WTF?");
	exit(-1);
}

int main() {
	scanf("%lld%lld%lld", &N, &X, &Y);
	findL();
    process();
	return 0;
}

Compilation message

aliens.cpp: In function 'bool ask(ll, ll)':
aliens.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %s", str);
  ~~~~~^~~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:121:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld", &N, &X, &Y);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 516 KB Output is correct
2 Correct 3 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 584 KB Output is correct
2 Correct 3 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 584 KB Output is correct
2 Correct 3 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 1164 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1164 KB Output is correct
2 Execution timed out 1065 ms 31352 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 3 ms 31352 KB Output is correct
2 Runtime error 19 ms 31352 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 31584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 31584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 402 ms 31584 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -