Submission #650013

#TimeUsernameProblemLanguageResultExecution timeMemory
650013taulantFloppy (RMI20_floppy)C++14
100 / 100
82 ms15508 KiB
#include "bits/stdc++.h" #include "floppy.h" using namespace std; array<int, 2> t[16][42069]; int mx(int l, int r){ int y = 0, k = 1; while(k+k <= r-l) ++y, k *= 2; return max(t[y][l], t[y][r-k])[1]; } void read_array(int _, const vector<int> &v){ stack<int> s; string b; for(int i : v){ while(s.size() && s.top() < i){s.pop(); b += '0';} s.push(i); b += '1'; } save_to_floppy(b); } vector<int> solve_queries(int _, int n, const string &b, const vector<int> &l, const vector<int> &r){ vector<int> v, ans; int x = 69420; for(char c : b){ if(c > 48) v.push_back(--x); else ++x; } for(int i = 0; i < n; ++i) t[0][i] = {v[i], i}; for(int y = 0; y < 15; ++y){ int p = 1 << y; for(int i = 0; i+p+p <= n; ++i) t[y+1][i] = max(t[y][i], t[y][i+p]); } for(int i = 0; i < l.size(); ++i) ans.push_back(mx(l[i], r[i]+1)); return ans; }

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:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int i = 0; i < l.size(); ++i) ans.push_back(mx(l[i], r[i]+1));
      |                 ~~^~~~~~~~~~
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...