Submission #404501

#TimeUsernameProblemLanguageResultExecution timeMemory
404501danielcm585Floppy (RMI20_floppy)C++14
100 / 100
126 ms15780 KiB
#include "floppy.h" #include <bits/stdc++.h> using namespace std; void read_array(int subtask_id, const vector<int> &v) { string bits; stack<int> s; for (auto i : v) { while (!s.empty() && s.top() < i) { bits += '0'; s.pop(); } bits += '1'; s.push(i); } save_to_floppy(bits); } vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &l, const vector<int> &r) { stack<int> s; vector<vector<int>> ls(N,vector<int>(16)); for (int i = 0, j = 0; i < bits.length(); i++) { if (bits[i] == '1') { if (s.empty()) ls[j][0] = j; else ls[j][0] = s.top(); s.push(j++); } else s.pop(); } for (int i = 1; i < 16; i++) { for (int j = 0; j < N; j++) { ls[j][i] = ls[ls[j][i-1]][i-1]; } } vector<int> res; for (int i = 0; i < l.size(); i++) { int ans = r[i]; for (int j = 15; j >= 0; j--) { if (ls[ans][j] >= l[i]) ans = ls[ans][j]; } res.push_back(ans); } return res; }

Compilation message (stderr)

floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:23:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i = 0, j = 0; i < bits.length(); i++) {
      |                            ~~^~~~~~~~~~~~~~~
floppy.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i = 0; i < l.size(); i++) {
      |                     ~~^~~~~~~~~~
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...