Submission #415222

#TimeUsernameProblemLanguageResultExecution timeMemory
415222fvogel499cmp (balkan11_cmp)C++14
Compilation error
0 ms0 KiB
/* File created on 05/31/2021 at 18:32:22. Link to problem: https://oj.uz/problem/view/balkan11_cmp Description: https://usaco.guide/adv/interactive?lang=cpp#tip-1---dont-send-everything Time complexity: irrelevant Space complexity: irrelevant Status: DEV Copyright: Ⓒ 2021 Francois Vogel */ #include <iostream> #include <vector> #include "cmp.h" using namespace std; vector<int> start = {0, 4, 20, 84, 340, 965, 2261}; // const int N = 10241; // bool bits [N]; // void bit_set(int i) { // bits[i] = true; // } // void bit_reset(int i) { // bits[i] = false; // } // bool bit_get(int i) { // return bits[i]; // } void remember(int n) { for (int i = 0; i < 6; i++) { int cons = n>>(2*(5-i)); bit_set(cons+start[i]+1); } } void undo(int n) { for (int i = 0; i < 6; i++) { int cons = n>>(2*(5-i)); bit_reset(cons+start[i]+1); } } int compare(int n) { int l = 0; int r = 5; while (l <= r) { int mid = (l+r)/2; if (l+1 == r) mid++; int cons = n>>(2*(5-mid)); bool res = bit_get(start[mid]+cons+1); if (res) { l = mid; if (r == l) break; } else r = mid-1; } if (l == 5 and r == 5) return 0; if (r == -1 and l == 0) l = 0; else l++; int cons = n>>(2*(5-l)); if (cons%4 == 0) return -1; else if (cons%4 == 3) return 1; else if (cons%4 == 1) { bool res = bit_get(start[l]+cons-1+1); if (res) return 1; else return -1; } else if (cons%4 == 2) { bool res = bit_get(start[l]+cons+1+1); if (res) return -1; else return 1; } } // int main() { // for (int i = 0; i < N; i++) bits[i] = false; // int lim = 4096; // for (int i = 0; i < lim; i++) { // if (i%200 == 0) cout << endl << "PROGRESS: " << (i*100)/lim << " |"; // else if (i%100 == 0) cout << "."; // for (int j = 0; j < 4096; j++) { // // cout << endl << "RUNNING: " << i << " " << j; // remember(i); // int res = compare(j); // undo(i); // if ((res == 0 and i != j) or (res == -1 and i <= j) or (res == 1 and i >= j)) { // cout << endl << "-> PROBLEM: " << i << " " << j; // } // } // } // int d = 0; // d++; // }

Compilation message (stderr)

cmp.cpp: In function 'void undo(int)':
cmp.cpp:41:9: error: 'bit_reset' was not declared in this scope; did you mean 'bit_set'?
   41 |         bit_reset(cons+start[i]+1);
      |         ^~~~~~~~~
      |         bit_set
cmp.cpp: In function 'int compare(int)':
cmp.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^