Submission #645530

#TimeUsernameProblemLanguageResultExecution timeMemory
645530Alex_tz307Floppy (RMI20_floppy)C++17
100 / 100
89 ms12112 KiB
#include <bits/stdc++.h> #include "floppy.h" using namespace std; vector<int> solve_queries(int subtask_id, int n, const string &bits, const vector<int> &a, const vector<int> &b) { vector<int> lg2(n + 1); for (int i = 2; i <= n; ++i) { lg2[i] = lg2[i / 2] + 1; } vector<vector<int>> nxt(n + 1, vector<int>(lg2[n] + 1, n)); vector<int> stk; int ptr = 0; for (int i = 0; i < n; ++i) { while (bits[ptr] == '0') { nxt[stk.back()][0] = i; stk.pop_back(); ptr += 1; } stk.emplace_back(i); ptr += 1; } for (int j = 1; j <= lg2[n]; ++j) { for (int i = 0; i < n; ++i) { nxt[i][j] = nxt[nxt[i][j - 1]][j - 1]; } } int m = a.size(); vector<int> res(m); for (int i = 0; i < m; ++i) { int l = a[i], r = b[i]; for (int j = lg2[r - l + 1]; j >= 0; --j) { if (nxt[l][j] <= r) { l = nxt[l][j]; } } res[i] = l; } return res; } void read_array(int subtask_id, const vector<int> &v) { int n = v.size(); vector<int> stk; string bits = ""; for (int i = 0; i < n; ++i) { while (!stk.empty() && stk.back() < v[i]) { stk.pop_back(); bits += '0'; } stk.emplace_back(v[i]); bits += '1'; } save_to_floppy(bits); }

Compilation message (stderr)

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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...