Submission #1056539

#TimeUsernameProblemLanguageResultExecution timeMemory
1056539VanillaFloppy (RMI20_floppy)C++17
28 / 100
1128 ms12104 KiB
#include <bits/stdc++.h> #include "floppy.h" using namespace std; void read_array(int subtask_id, const vector<int> &v) { string s = ""; stack <int> st; int n = v.size(); for (int i = 0; i < n; i++){ while (!st.empty() && v[i] > st.top()) { st.pop(); s.push_back('0'); } st.push(v[i]); s.push_back('1'); } save_to_floppy(s); } vector<int> solve_queries(int subtask_id, int n, const string &bits, const vector<int> &a, const vector<int> &b) { stack <int> st; st.push(-1); vector <int> high(n); int idx = 0; for (char c: bits) { if (c == '1') { high[idx] = st.top(); st.push(idx++); } else { st.pop(); } } vector <int> rs; for (int i = 0; i < a.size(); i++){ int l = a[i], r = b[i], last = b[i]; while (r != high[r] && r >= l) { last = r; r = high[r]; } rs.push_back(last); } return rs; }

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