Submission #580754

# Submission time Handle Problem Language Result Execution time Memory
580754 2022-06-21T18:17:13 Z Omar_Elgedawy Lost in the cycle (IOI19_cycle) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.cpp"
using namespace std;#include <bits/stdc++.h>
// #include "grader.cpp"
#include "cycle.h"
using namespace std;

void escape(int n) {
	if(jump(0)){
		if(jump(n/2+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;
			if(jump(dist)){
				r=m-1;
				one=loc;
			}
			else{
				l=m+1;
			}
		}
		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);
		}
		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;
			if(jump(dist)){
				r=m-1;
				one=loc;
			}
			else{
				l=m+1;
			}
		}
		if(loc<one)
			jump(one-loc);
		else if(loc>one)
			jump((n-loc)+one);
		jump(n/2);
	}
}


void escape(int n) {
	if(jump(0)){
		if(jump(n/2+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;
			if(jump(dist)){
				r=m-1;
				one=loc;
			}
			else{
				l=m+1;
			}
		}
		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);
		}
		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;
			if(jump(dist)){
				r=m-1;
				one=loc;
			}
			else{
				l=m+1;
			}
		}
		if(loc<one)
			jump(one-loc);
		else if(loc>one)
			jump((n-loc)+one);
		jump(n/2);
	}
}

Compilation message

cycle.cpp:3:21: error: stray '#' in program
    3 | using namespace std;#include <bits/stdc++.h>
      |                     ^
cycle.cpp:3:22: error: 'include' does not name a type
    3 | using namespace std;#include <bits/stdc++.h>
      |                      ^~~~~~~
cycle.cpp:70:6: error: redefinition of 'void escape(int)'
   70 | void escape(int n) {
      |      ^~~~~~
cycle.cpp:8:6: note: 'void escape(int)' previously defined here
    8 | void escape(int n) {
      |      ^~~~~~