답안 #856251

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856251 2023-10-02T21:54:31 Z divad Floppy (RMI20_floppy) C++14
100 / 100
93 ms 39124 KB
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
const int NMAX = 4e5+2;
const int LMAX = 20;
int bigr[LMAX][NMAX], st[NMAX], vf;

void read_array(int subtask_id, const vector<int> &v) {
    string bits = "";
    int n = v.size();
    vf = 0;
    for(int i = 0; i < n; i++){
        while(vf > 0 && st[vf] < v[i]){
            bits += "1";
            vf--;
        }
        st[++vf] = v[i];
        bits += "0";
    }
    save_to_floppy(bits);
}

vector<int> solve_queries(int subtask_id, int N,
        const string &bits,
        const vector<int> &a, const vector<int> &b) {
    int n = N, m = a.size();
    vf = 0;
    int pos = 0;
    for(int i = 1; i <= n; i++){
        while(bits[pos] == '1'){
            vf--;
            pos++;
        }
        bigr[0][i] = st[vf];
        st[++vf] = i;
        pos++;
    }
    for(int i = 1; i < LMAX; i++){
        for(int j = 1; j <= n; j++){
            bigr[i][j] = bigr[i-1][bigr[i-1][j]];
        }
    }
    vector<int> ans;
    for(int i = 0; i < m; i++){
        int l = a[i], r = b[i];
        l++, r++;
        int id = r;
        for(int j = LMAX-1; j >= 0; j--){
            if(bigr[j][id] >= l){
                id = bigr[j][id];
            }
        }
        ans.push_back(id-1);
    }
    return ans;
}

Compilation message

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 4 ms 31528 KB Output is correct
2 Correct 4 ms 31528 KB Output is correct
3 Correct 4 ms 31528 KB Output is correct
4 Correct 4 ms 31788 KB Output is correct
5 Correct 4 ms 31532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 33472 KB Output is correct
2 Correct 19 ms 33324 KB Output is correct
3 Correct 19 ms 33328 KB Output is correct
4 Correct 19 ms 33320 KB Output is correct
5 Correct 19 ms 33344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 39124 KB Output is correct
2 Correct 69 ms 39052 KB Output is correct
3 Correct 93 ms 39072 KB Output is correct
4 Correct 82 ms 39068 KB Output is correct
5 Correct 69 ms 38928 KB Output is correct