답안 #650013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
650013 2022-10-11T21:15:46 Z taulant Floppy (RMI20_floppy) C++14
100 / 100
82 ms 15508 KB
#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

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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 808 KB Output is correct
2 Correct 2 ms 816 KB Output is correct
3 Correct 2 ms 812 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 2 ms 804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 4248 KB Output is correct
2 Correct 20 ms 4276 KB Output is correct
3 Correct 19 ms 4228 KB Output is correct
4 Correct 20 ms 4244 KB Output is correct
5 Correct 22 ms 4364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 13996 KB Output is correct
2 Correct 79 ms 15400 KB Output is correct
3 Correct 74 ms 15216 KB Output is correct
4 Correct 82 ms 15508 KB Output is correct
5 Correct 82 ms 15472 KB Output is correct