Submission #821776

#TimeUsernameProblemLanguageResultExecution timeMemory
821776LucaLucaMFloppy (RMI20_floppy)C++17
0 / 100
61 ms8136 KiB
#include <bits/stdc++.h> #include "floppy.h" using namespace std; void read_array(int subtask_id, const std::vector<int> &v) { int n = (int) v.size(); stack<int>st; string bits = ""; for (int i = 0; i < n; i++) { while (!st.empty() && v[i] >= v[st.top()]) { st.pop(); bits += "0"; } st.push(i); bits += "1"; } 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) { vector<int>answer; int n = (int) bits.size(); n >>= 1; vector<int>l(n + 1); int sz = 0; for (int i = 0, j = 0; i < (int) bits.size(); i++) { if (bits[i] == '0') { sz--; } else { l[++j] = sz; sz++; } } for (int q = 0; q < (int) a.size(); q++) { int st = a[q] + 1, dr = b[q] + 1; int p = dr; while (l[p] >= st) p = l[p]; answer.push_back(p - 1); } return answer; }

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