Submission #1295375

#TimeUsernameProblemLanguageResultExecution timeMemory
1295375enzycmp (balkan11_cmp)C++20
100 / 100
959 ms96156 KiB
#include "cmp.h" #include<bits/stdc++.h> using namespace std; void remember(int n){ int cnt=1; for(int i=2;i<=12;i+=2){ int a=(n>>(12-i)); // pegando so os primeiros i bits do numero bit_set(cnt+a); cnt+=(1<<i); } } bool check(int x, int k){ // checar se o pref de 2*k caras eh igual int q=(x>>(12-2*k)), cnt=1; for(int i=2;i<2*k;i+=2) cnt+=(1<<i); return bit_get(q+cnt); } int get_chunk(int x, int k){ int aux=(x>>(12-2*k-2)); //cout << "? " << bitset<12>(aux) << " " << aux << " " << x << " " << k << endl; return aux%4; } int final(int x, int y, int k){ int cnt=1; for(int i=2;i<2*k;i+=2) cnt+=(1<<i); int aux=(x>>(12-2*k)); aux+=y; // aumentando ou diminuindo 1 return bit_get(aux+cnt); } int compare(int b){ int l=0, r=6, resp=0; // qtd de caras iguais no prefixo while(l<=r){ int mid=(l+r)/2; if(check(b,mid)) resp=mid, l=mid+1; else r=mid-1; } //cout << "a " << resp << endl; if(resp==6) return 0; // totalmente igual // se eh diferente, ver a chunk boa, ela eh 00 ou 01 ou 10 ou 11 int at=get_chunk(b,resp); //cout << "! " << bitset<12>(b) << " " << at << endl; if(at==0) return -1; if(at==3) return 1; if(at==1){ if(final(b,-1,resp+1)) return 1; // se ele tem o at=0, ent a<b else return -1; // se n a>b } if(at==2){ if(final(b,1,resp+1)) return -1; // se ele tem o at=3, ent a>b else return 1; // se n a<b } }

Compilation message (stderr)

cmp.cpp: In function 'int compare(int)':
cmp.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...