답안 #855915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855915 2023-10-02T09:02:16 Z Peti Floppy (RMI20_floppy) C++17
100 / 100
71 ms 13760 KB
#include <bits/stdc++.h>
#include "floppy.h"

using namespace std;

void read_array ( int subtask_id , const std :: vector<int> &v ) {
    vector<int> q;
    string bits = "";
    for(int x : v){
        while(!q.empty() && q.back() < x) {
            q.pop_back();
            bits += '0';
        }
        q.push_back(x);
        bits += '1';
    }
    save_to_floppy(bits);
}

std::vector<int> solve_queries ( int subtask_id , int N, const std::string &bits, const std::vector<int> &a, const std::vector<int> &b) {
    int m = (int)a.size();
    vector<vector<int>> queries(N);
    for(int i = 0; i < m; i++){
        queries[b[i]].push_back(i);
    }
    int idx = -1;
    vector<int> q, res(m);
    for(char b : bits){
        if(b == '1'){
            q.push_back(++idx);
            for(int i : queries[idx]){
                res[i] = *lower_bound(q.begin(), q.end(), a[i]);
            }
        } else {
            q.pop_back();
        }
    }
    return res;
}

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 1 ms 820 KB Output is correct
2 Correct 1 ms 820 KB Output is correct
3 Correct 1 ms 824 KB Output is correct
4 Correct 2 ms 824 KB Output is correct
5 Correct 1 ms 924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 3780 KB Output is correct
2 Correct 16 ms 3772 KB Output is correct
3 Correct 17 ms 3628 KB Output is correct
4 Correct 16 ms 3776 KB Output is correct
5 Correct 16 ms 3868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 13380 KB Output is correct
2 Correct 64 ms 13664 KB Output is correct
3 Correct 71 ms 13760 KB Output is correct
4 Correct 66 ms 13496 KB Output is correct
5 Correct 65 ms 13112 KB Output is correct