Submission #494456

#TimeUsernameProblemLanguageResultExecution timeMemory
494456iulia13Floppy (RMI20_floppy)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "floppy.h" using namespace std; const int NMAX = 40005; const int LG = 20; int st[NMAX]; int rmq[NMAX][LG]; int lft[NMAX]; ///void save_to_floppy(string &bits); void read_array(int subtask_id, const vector <int> &v) { string a = ""; int k = 0, n = v.size(); for (int i = 0; i < n; i++) { while (k && st[k] < v[i]) { a += '1'; k--; } st[++k] = v[i]; a += '0'; } save_to_floppy(a); } vector <int> sol; int lg[N]; vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) { int k = 0, m = bits.size(), jj = 0; for (int i = 1; i <= N; i++) { if (1 < i) lg[i] = 1 + lg[i / 2]; while(k && bits[jj] == '1') k--, jj++; jj++; lft[i] = st[k]; st[++k] = i; rmq[i][0] = i; } for (int j = 1; (1 << j) <= N; j++) for (int i = 1; i <= N; i++) { rmq[i][j] = rmq[i][j - 1]; if (lft[rmq[i + (1 << (j - 1))][j - 1]] < i) rmq[i][j] = rmq[i + (1 << (j - 1))][j - 1]; } int q = a.size(); for (int i = 0; i < q; i++) { int aa = a[i], bb = b[i]; aa++, bb++; int lgg = lg[bb - aa + 1]; int ans = rmq[aa][lgg]; if (lft[rmq[bb - (1 << lgg) + 1][lgg]] < aa) ans = rmq[bb - (1 << lgg) + 1][lgg]; sol.push_back(ans - 1); } return sol; }

Compilation message (stderr)

floppy.cpp:27:8: error: 'N' was not declared in this scope
   27 | int lg[N];
      |        ^
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:34:13: error: 'lg' was not declared in this scope; did you mean 'log'?
   34 |             lg[i] = 1 + lg[i / 2];
      |             ^~
      |             log
floppy.cpp:54:19: error: 'lg' was not declared in this scope; did you mean 'lgg'?
   54 |         int lgg = lg[bb - aa + 1];
      |                   ^~
      |                   lgg
floppy.cpp:30:16: warning: unused variable 'm' [-Wunused-variable]
   30 |     int k = 0, m = bits.size(), jj = 0;
      |                ^
stub.cpp: In function 'void run2()':
stub.cpp:101:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     if (query_answers.size() != M) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~