Submission #876474

#TimeUsernameProblemLanguageResultExecution timeMemory
876474MinaRagy06Floppy (RMI20_floppy)C++17
28 / 100
27 ms6580 KiB
#include <bits/stdc++.h> #include "floppy.h" #ifdef MINA #include "grader.cpp" #endif using namespace std; #define ll long long void read_array(int sub, const vector<int> &v) { vector<int> vals; for (auto i : v) { vals.push_back(i); } sort(vals.begin(), vals.end()); string s; int cnt = __lg(v.size() - 1) + 1; for (auto i : v) { int x = lower_bound(vals.begin(), vals.end(), i) - vals.begin(); for (int j = 0; j < cnt; j++) { s.push_back(((x >> j) & 1) + '0'); } } save_to_floppy(s); } vector<int> solve_queries(int sub, int n, const string &bits, const vector<int> &a, const vector<int> &b) { pair<int, int> sparse[16][n]; for (int j = 0; j < 16; j++) { for (int i = 0; i < n; i++) { sparse[j][i] = {0, -1}; } } int cnt = __lg(n - 1) + 1; for (int i = 0; i < n; i++) { for (int j = 0; j < cnt; j++) { if (bits[cnt * i + j] == '1') { sparse[0][i].first |= 1 << j; } } sparse[0][i].second = i; } for (int j = 1; j < 16; j++) { for (int i = 0; i + (1 << (j - 1)) < n; i++) { sparse[j][i] = max(sparse[j - 1][i], sparse[j - 1][i + (1 << (j - 1))]); } } int q = a.size(); vector<int> ans(q); for (int i = 0; i < q; i++) { int lg = __lg(b[i] - a[i] + 1); ans[i] = max(sparse[lg][a[i]], sparse[lg][b[i] - (1 << lg) + 1]).second; } return ans; }

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...