Submission #746307

#TimeUsernameProblemLanguageResultExecution timeMemory
746307dooweyFloppy (RMI20_floppy)C++14
100 / 100
968 ms12204 KiB
#include <bits/stdc++.h> #include "floppy.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair void read_array(int subtask_id, const vector<int> &v) { string bits; vector<int> idx; for(int i = 0 ; i < v.size(); i ++ ){ bits.push_back('1'); while(!idx.empty() && v[idx.back()] < v[i]){ bits.push_back('0'); idx.pop_back(); } idx.push_back(i); } save_to_floppy(bits); } vector<int> solve_queries(int subtask_id, int n, const string &bits, const vector<int> &a, const vector<int> &b) { vector<int> answers = {}; int p = 0; vector<int> L(n); vector<int> st; for(int i = 0 ; i < n; i ++ ){ p ++ ; while(p < bits.size() && bits[p] == '0'){ st.pop_back(); p ++ ; } if(st.empty()) L[i] = -1; else L[i] = st.back(); st.push_back(i); } int m = a.size(); int big; for(int i = 0 ; i < m ; i ++ ){ big = -1; for(int j = a[i]; j <= b[i]; j ++ ){ if(L[j] < a[i]){ big = j; } } answers.push_back(big); } return answers; }

Compilation message (stderr)

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