답안 #369239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369239 2021-02-21T01:37:49 Z chienyu_xiong Lost in the cycle (IOI19_cycle) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

/*
bool jump(int dis) {
	return jump(dis);
	//tmp += dis;
	//tmp %= n;
	//return tmp == 0 || tmp > (n / 2);
}
*/
void escape(int n) {
	auto amount = [](int src, int dst, int n) {
		return (dst - src + n) % n;
	};
	
	bool val = jump(0);
	
	if (!val) {
		//cout << "debug" << endl;
		if (!jump((n + 1) / 2)) {
			jump(n - 1); return;
		}
	}
	
	int cur = 0;
	int lo = 0;
	int hi = n / 2;
	while (lo < hi) {
		int mid = (lo + hi + 1) / 2;
		
		int cng = amount(cur, mid, n);
		if (!jump(cng)) hi = mid - 1;
		else lo = mid;		
		cur = mid;
		
		//cout << lo << " " << hi << ": " << cur << endl;
	}
	
	jump(amount(cur, lo, n));
}





















Compilation message

cycle.cpp: In function 'void escape(int)':
cycle.cpp:18:13: error: 'jump' was not declared in this scope
   18 |  bool val = jump(0);
      |             ^~~~