Submission #52538

#TimeUsernameProblemLanguageResultExecution timeMemory
52538someone_aacmp (balkan11_cmp)C++17
0 / 100
1175 ms105044 KiB
#include "cmp.h" #include <vector> using namespace std; void remember(int n) { int node = 1; for(int i=11;i>=0;i--) { bit_set(node); if(n&(1<<i)) node = 2 * node + 1; else node = 2 * node; } bit_set(node); } int compare(int b) { //edit this int node = 1; vector<int>nodes; for(int i=11;i>=0;i--) { nodes.push_back(node); if(b&(1<<i)) node = 2 * node + 1; else node = 2 * node; } nodes.push_back(node); int li = 0, ri = nodes.size()-1; while(li < ri) { int mid = (li+ri)/2; if(bit_get(nodes[mid])) ri = mid; else li = mid + 1; } if(li == nodes.size() -1) return 0; else { if(nodes[li] * 2 == nodes[li+1]) return -1; else return 1; } }

Compilation message (stderr)

cmp.cpp: In function 'int compare(int)':
cmp.cpp:32:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(li == nodes.size() -1) return 0;
        ~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...