답안 #596643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596643 2022-07-14T23:18:30 Z definitelynotmee Floppy (RMI20_floppy) C++17
0 / 100
93 ms 11300 KB
#include <stdlib.h>
#include <string.h>

#include "floppy.h"
#include<bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
using matrix = vector<vector<T>>;

void read_array(int subtask_id, const std::vector<int> &v) {
    int n = v.size();

    vector<int> jmp(n,-1);
    string bits;

    for(int i = 1; i < n; i++){
        jmp[i] = i-1;
        while(jmp[i]!=-1 && v[jmp[i]] < v[i])
            jmp[i] = jmp[jmp[i]], bits.push_back('0');
        bits.push_back('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) {
    vector<int> answers(b.size());
    
    vector<int> jmp(n,-1);
    int ptr = 0;

    for(int i = 1; i < n; i++){
        jmp[i] = i-1;
        while(true){
            if(bits[ptr++] == '0'){
                jmp[i] = jmp[jmp[i]];
            } else break;
        }
    }
    matrix<int> lift(20,vector<int>(n));
    for(int i = 0; i < n; i++){
        lift[0][i] = jmp[i];
    }

    for(int i = 1; i < 20; i++){
        for(int j = 0; j < n; j++){
            lift[i][j] = lift[i-1][lift[i-1][j]];
        }
    }
    for(int i = 0; i < a.size(); i++){
        int id = b[i];
        for(int j = 19; j >= 0; j--){
            if(lift[j][id] >= a[i])
                id = lift[j][id];
        }
        answers[i] = id;
    }

    return answers;
}

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:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i = 0; i < a.size(); i++){
      |                    ~~^~~~~~~~~~
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 Incorrect 2 ms 792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 3228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 11300 KB Output isn't correct
2 Halted 0 ms 0 KB -