Submission #68381

# Submission time Handle Problem Language Result Execution time Memory
68381 2018-08-17T03:35:14 Z nvmdava Aliens (IOI07_aliens) C++17
0 / 100
3 ms 476 KB
#include <bits/stdc++.h>
using namespace std;

int n;

bool ask(int x, int y){
	if(x > n || x < 1 || y > n || y < 1){
		return 0;
	}
	printf("examine %d %d", x, y);
	fflush(stdout);
	string s;
	scanf("%s", &s);
	return (s[0] == 't');
}

int x, y, m;

int main(){
	cin>>n>>x>>y;
	int left, right, up, down;
	
	int l = 0, r = x;
	while(l + 1 != r){
		int m = (l + r) / 2;
		if(ask(m, y)){
			r = m;
		} else {
			l = m;
		}
	}
	left = l;
	
	l = x, r = n + 1;
	while(l + 1 != r){
		int m = (l + r) / 2;
		if(ask(m, y)){
			l = m;
		} else {
			r = m;
		}
	}
	right = l;
	
	l = 0, r = y;
	while(l + 1 != r){
		int m = (l + r) / 2;
		if(ask(x, m)){
			r = m;
		} else {
			l = m;
		}
	}
	up = l;
	
	l = y, r = n + 1;
	while(l + 1 != r){
		int m = (l + r) / 2;
		if(ask(x, m)){
			l = m;
		} else {
			r = m;
		}
	}
	down = l;
	m = __gcd(right - left, down - up);
	
	right = left + m;
	down = up + m;
	x = (right + left) / 2 + 1;
	y = (down + up) / 2 + 1;
	
	printf("solution %d %d\n", x, y);
}

Compilation message

aliens.cpp: In function 'bool ask(int, int)':
aliens.cpp:13:16: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'std::__cxx11::string* {aka std::__cxx11::basic_string<char>*}' [-Wformat=]
  scanf("%s", &s);
              ~~^
aliens.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", &s);
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 292 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3 ms 460 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2 ms 476 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -