Submission #348005

#TimeUsernameProblemLanguageResultExecution timeMemory
348005laoriuLost in the cycle (IOI19_cycle)C++14
100 / 100
1 ms364 KiB

#include <bits/stdc++.h>
#include "cycle.h"
using namespace std;

void escape(int n){
    int st=0;
    if(jump(0)){
        if(jump(1)){
            st=1;
            int b=1,e=n/2,ans;
            while(b<=e){
                int m=b+e>>1;
                if(jump((m-st+n)%n)){
                    b=m+1;ans=m;
                }
                else e=m-1;
                st=m;
            }
            jump((ans-st+n)%n);
        }
        else {
            jump(n-1);return;
        }
    }
    else{
            jump(n/2);
            int b=1,e=n/2,ans;
            while(b<=e){
                int m=b+e>>1;
                if(jump((m-st+n)%n)){
                    b=m+1;ans=m;
                }
                else e=m-1;
                st=m;
            }
            jump((ans-st+n)%n);
    }
}

Compilation message (stderr)

cycle.cpp: In function 'void escape(int)':
cycle.cpp:13:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |                 int m=b+e>>1;
      |                       ~^~
cycle.cpp:30:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |                 int m=b+e>>1;
      |                       ~^~
cycle.cpp:37:25: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |             jump((ans-st+n)%n);
      |                  ~~~~~~~^~~
cycle.cpp:20:22: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |             jump((ans-st+n)%n);
      |                   ~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...