Submission #854874

#TimeUsernameProblemLanguageResultExecution timeMemory
854874tibinyteFloppy (RMI20_floppy)C++14
28 / 100
47 ms8636 KiB
#include <bits/stdc++.h> using namespace std; struct aint { vector<int> a; void resize(int n) { a = vector<int>(4 * n); } void update(int node, int left, int right, int pos, int val) { if (left == right) { a[node] = val; return; } int mid = (left + right) / 2; if (pos <= mid) { update(2 * node, left, mid, pos, val); } else { update(2 * node + 1, mid + 1, right, pos, val); } a[node] = max(a[2 * node], a[2 * node + 1]); } int query(int node, int left, int right, int st, int dr) { if (right < st || left > dr) { return 0; } if (st <= left && dr >= right) { return a[node]; } int mid = (left + right) / 2; return max(query(2 * node, left, mid, st, dr), query(2 * node + 1, mid + 1, right, st, dr)); } }; #include "floppy.h" void read_array(int subtask_id, const std::vector<int> &v) { int n = (int)v.size(); map<int, int> who; vector<int> lying = v; sort(lying.begin(), lying.end()); for (auto i : lying) { if (who.find(i) == who.end()) { int p = (int)who.size(); who[i] = p; } } vector<int> a(n); for (int i = 0; i < n; ++i) { a[i] = who[v[i]]; } int lg = log2(n); string bits; for (int i = 0; i < n; ++i) { for (int j = 0; j <= lg; ++j) { if (a[i] & (1 << j)) { bits += '1'; } else { bits += '0'; } } } save_to_floppy(bits); } std::vector<int> solve_queries(int subtask_id, int n, const std::string &bits, const std::vector<int> &a, const std::vector<int> &b) { int sz = (int)bits.size(); int lg = log2(n) + 1; vector<int> x; for (int st = 0; st < sz; st += lg) { int rep = 0; int dr = st + lg - 1; for (int j = st; j <= dr; ++j) { if (bits[j] == '1') { rep += (1 << (j - st)); } } x.push_back(rep); } vector<int> pos(n); for(int i = 0; i < n; ++i){ pos[x[i]] = i; } aint tree; tree.resize(n); for(int i= 0 ; i < n; ++i){ tree.update(1,1,n,i+1,x[i]); } vector<int> answers; for(int i= 0; i < (int)a.size(); ++i){ int st = a[i]; int dr = b[i]; answers.push_back(pos[tree.query(1,1,n,st+1,dr+1)]); } return answers; }

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