답안 #580745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580745 2022-06-21T18:04:20 Z Omar_Elgedawy Lost in the cycle (IOI19_cycle) C++14
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
#include "cycle.h"
using namespace std;

void escape(int n) {
	if(jump(0)){
		if(jump(n/2)){
			return;
		}
		jump(n/2+n%2);
		int loc=0,one=0;
		int l=n/2,r=n-1;
		while(l<=r){
			int m=(r+l)/2;
			int dist;
			if(m>loc)
				dist=m-loc;
			else
				dist=((n-loc)+m)%n;
			loc=(loc+dist)%n;
			// cout<<l<<' '<<r<<' '<<m<<' '<<dist<<' '<<loc<<endl;
			if(jump(dist)){
				r=m-1;
				one=loc;
			}
			else{
				l=m+1;
			}
		}
		cout<<loc<<' '<<one<<' ';
		if(loc<one){
			loc=(loc+(one-loc))%n;
			jump(one-loc);
		}
		else if(loc>one){
			loc=(loc+(n-loc)+one)%n;
			jump(((n-loc)+one)%n);
		}
		cout<<(loc+n/2)%n<<endl;
		jump(n/2);
	}
	else{
		int loc=0,one;
		int l=1,r=n/2+1;
		while(l<=r){
			int m=(r+l)/2;
			int dist;
			if(m>loc)
				dist=m-loc;
			else
				dist=(n-loc)+m;
			loc=(loc+dist)%n;
			// cout<<l<<' '<<r<<' '<<m<<' '<<dist<<' '<<loc<<endl;
			if(jump(dist)){
				r=m-1;
				one=loc;
			}
			else{
				l=m+1;
			}
		}
		// cout<<loc<<' '<<one;
		if(loc<one)
			jump(one-loc);
		else if(loc>one)
			jump((n-loc)+one);
		jump(n/2);
	}
}

Compilation message

cycle.cpp: In function 'void escape(int)':
cycle.cpp:66:8: warning: 'one' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |    jump((n-loc)+one);
      |    ~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Incorrect 1 ms 208 KB The exit was not found.
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB The exit was not found.
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Incorrect 1 ms 208 KB The exit was not found.
14 Halted 0 ms 0 KB -