Submission #856161

#TimeUsernameProblemLanguageResultExecution timeMemory
856161gortomiFloppy (RMI20_floppy)C++17
100 / 100
71 ms13740 KiB
#include <stdlib.h> #include <string.h> #include "floppy.h" #include <bits/stdc++.h> using namespace std; void read_array(int subtask_id, const vector<int> &v) { stack<int> s; int n = v.size(); s.push(1e9 + 1); string bits = ""; for(auto x : v) { while(s.top() < x) { s.pop(); bits += '1'; } bits += '0'; s.push(x); } save_to_floppy(bits); } vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) { int m = a.size(); vector<int> ans(m); vector<vector<pair<int, int> > > query(N); for(int i = 0; i < m; i++) { query[b[i]].push_back({a[i], i}); } vector<int> c; int k = 0; for(int i = 0; i < N; i++) { while(bits[k] != '0') { c.pop_back(); k++; } k++; c.push_back(i); for(auto [l, ind] : query[i]) { ans[ind] = *lower_bound(c.begin(), c.end(), l); } } return ans; }

Compilation message (stderr)

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:9:9: warning: unused variable 'n' [-Wunused-variable]
    9 |     int n = v.size();
      |         ^
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...