Submission #52613

#TimeUsernameProblemLanguageResultExecution timeMemory
52613someone_aacmp (balkan11_cmp)C++17
46 / 100
6787 ms104984 KiB
#include "cmp.h" #include <vector> using namespace std; void remember(int n) { int node = 1; for(int i=11;i>=0;i--) { if(node != 1) bit_set(node); //bit[node] = true; if(n&(1<<i)) node = 2 * node + 1; else node = 2 * node; } //bit[node] = true; 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; int f = -1; while(li <= ri) { int mid = (li+ri)/2; bool check = false; if(mid == 0) check = true; else check = bit_get(nodes[mid]); if(check) { li = mid + 1; f = mid; } else ri = mid - 1; } if(f == nodes.size() -1) return 0; else { if(nodes[f] * 2 == nodes[f+1]) return -1; else return 1; } }

Compilation message (stderr)

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