Submission #307944

# Submission time Handle Problem Language Result Execution time Memory
307944 2020-09-29T15:44:46 Z sean9892 Lost in the cycle (IOI19_cycle) C++14
0 / 100
0 ms 256 KB
#include "cycle.h"

int distance(int pos,int tar,int n){
	return (tar-pos+n)%n;
}

void escape(int n) {
	int pos=0;
	int N;
	N=n/2*2;
	int l=0,r=N;
	while(l<r){
		int m=l+r>>1;
		bool x=jump(distance(pos,m,n));
		pos=m;
		if(x){
			l=m;
		}
		else{
			r=m;
		}
		if(r-l<=5){
			break;
		}
	}
	for(int i=r-1;i>=l;i--){
		bool x=jump(distance(pos,i,n));
		pos=i;
		if(x){
			return;
		}
	}
	if(n&1)jump(distance(pos,N,n));
}

Compilation message

cycle.cpp: In function 'void escape(int)':
cycle.cpp:13:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |   int m=l+r>>1;
      |         ~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB The exit was not found.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB The exit was not found.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB The exit was not found.
4 Halted 0 ms 0 KB -