답안 #1060479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060479 2024-08-15T15:59:07 Z Halym2007 Aliens (IOI07_aliens) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define pii pair <int, int>
const int N = 2e5 + 5;


int n, sorag = 0;

bool ask (int jj, int kk) {
	if (jj > n or kk > n) return 0;
	if (jj < 1 or kk < 1) return 0;
	sorag++;
	assert (sorag <= 300);
	cout << "examine " << jj << " " << kk << endl;
	string s;
	cin >> s;
	if (s[0] == 't') return 1;
	return 0;
}


int main () {
//	freopen ("input.txt", "r", stdin);
//	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int a, b;
	cin >> n >> a >> b;
	m = 1;
	int l = a;r = a;
	while (l > 1) {
		if (!ask(l - 1)) {
			break;
		}
		l--;
		m++;
	}
	while (r < n) {
		if (!ask(r + 1)) break;
		r++;
		m++;
	}

	int l1 = a;r1 = a;
	while (l1 > 1) {
		if (!ask(l1 - 1)) {
			break;
		}
		l1--;
	}
	while (r1 < n) {
		if (!ask(r1 + 1)) break;
		r1++;
	}	
	
	int x = l1, y = r1;
	while (x > m) {
		if (!ask(x - m, y)) break;
		x -= m;
	}
	if (x > m and y + m <= n) {
		if (ask(x - m, y + m)) {
			x -= m;
			y += m;
		}
	}
	while (y + m <= n) {
		if (!ask (x, y + m)) {
			break;
		}
		y += m;
	}
	
	int jog1 = (x + 2 * m) + m / 2, jog2 = (y - 2 * m) - m / 2;
	cout << "solution " << jog1 << " " << jog2;
	
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:32:2: error: 'm' was not declared in this scope
   32 |  m = 1;
      |  ^
aliens.cpp:33:12: error: 'r' was not declared in this scope
   33 |  int l = a;r = a;
      |            ^
aliens.cpp:35:17: error: too few arguments to function 'bool ask(int, int)'
   35 |   if (!ask(l - 1)) {
      |                 ^
aliens.cpp:14:6: note: declared here
   14 | bool ask (int jj, int kk) {
      |      ^~~
aliens.cpp:47:13: error: 'r1' was not declared in this scope; did you mean 'l1'?
   47 |  int l1 = a;r1 = a;
      |             ^~
      |             l1
aliens.cpp:49:18: error: too few arguments to function 'bool ask(int, int)'
   49 |   if (!ask(l1 - 1)) {
      |                  ^
aliens.cpp:14:6: note: declared here
   14 | bool ask (int jj, int kk) {
      |      ^~~
aliens.cpp:78:40: error: 'jog2' was not declared in this scope; did you mean 'jog1'?
   78 |  cout << "solution " << jog1 << " " << jog2;
      |                                        ^~~~
      |                                        jog1