Submission #415213

#TimeUsernameProblemLanguageResultExecution timeMemory
415213fvogel499cmp (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; // } // 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); } } int compare(int n) { int l = 0; int r = 5; while (true) { int mid = (l+r)/2+1; 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; 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 a, b; // cin >> a >> b; // remember(a); // cout << compare(b); // int d = 0; // d++; // }

Compilation message (stderr)

cmp.cpp:17:1: error: 'vector' does not name a type
   17 | vector<int> start = {0, 4, 20, 84, 340, 965, 2261};
      | ^~~~~~
cmp.cpp: In function 'void remember(int)':
cmp.cpp:31:22: error: 'start' was not declared in this scope
   31 |         bit_set(cons+start[i]+1);
      |                      ^~~~~
cmp.cpp: In function 'int compare(int)':
cmp.cpp:41:28: error: 'start' was not declared in this scope
   41 |         bool res = bit_get(start[mid]+cons+1);
      |                            ^~~~~
cmp.cpp:54:28: error: 'start' was not declared in this scope
   54 |         bool res = bit_get(start[l]+cons-1+1);
      |                            ^~~~~
cmp.cpp:59:28: error: 'start' was not declared in this scope
   59 |         bool res = bit_get(start[l]+cons+1+1);
      |                            ^~~~~
cmp.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^