답안 #494454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494454 2021-12-15T13:26:50 Z iulia13 Floppy (RMI20_floppy) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
const int N = 40005;
const int LG = 20;
int st[N];
int rmq[N][LG];
int lft[N];
///void save_to_floppy(string &bits);
void read_array(int subtask_id, vector <int> &v)
{
    string a = "";
    int k = 0, n = v.size();
    for (int i = 0; i < n; i++)
    {
        while (k && st[k] < v[i])
        {
            a += '1';
            k--;
        }
        st[++k] = v[i];
        a += '0';
    }
    save_to_floppy(a);
}
vector <int> sol;
int lg[N];
vector<int> solve_queries(int subtask_id, int N, string &bits, vector<int> &A, vector<int> &B)
{
    int k = 0, m = bits.size(), jj = 0;
    for (int i = 1; i <= N; i++)
    {
        if (1 < i)
            lg[i] = 1 + lg[i / 2];
        while(k && bits[jj] == '1')
            k--, jj++;
        jj++;
        lft[i] = st[k];
        st[++k] = i;
        rmq[i][0] = i;
    }
    for (int j = 1; (1 << j) <= N; j++)
        for (int i = 1; i <= N; i++)
        {
            rmq[i][j] = rmq[i][j - 1];
            if (lft[rmq[i + (1 << (j - 1))][j - 1]] < i)
                rmq[i][j] = rmq[i + (1 << (j - 1))][j - 1];
        }
    int q = A.size();
    for (int i = 0; i < q; i++)
    {
        int a = A[i], b = B[i];
        a++, b++;
        int lgg = lg[b - a + 1];
        int ans = rmq[a][lgg];
        if (lft[rmq[b - (1 << lgg) + 1][lgg]] < a)
            ans = rmq[b - (1 << lgg) + 1][lgg];
        sol.push_back(ans - 1);
    }
    return sol;
}/*
#define NMAX 100000
#define MMAX 100000

int subtask_id, NN, M;
vector<int> v, sorted_v;
vector<int> a, b;
vector<int> correct_answers;

void read_test() {
    cin >> subtask_id >> NN >> M;
    v.resize(NN);
    for (int i = 0; i < NN; ++i) {
        cin >> v[i];
    }

    a.resize(M);
    b.resize(M);
    correct_answers.resize(M);
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i] >> correct_answers[i];
    }
}

void save_to_floppy(string &bits) {
    std::vector<int> contestant_answers = solve_queries(subtask_id, NN, bits, a, b);
    int x = contestant_answers.size();
    for (auto it : contestant_answers)
        cout << it << " ";
}

int main(int argc, char **argv) {
    // Read input data.
    read_test();

    // Send subtask_id, v.
    read_array(subtask_id, v);

    return 0;
}*/

Compilation message

floppy.cpp: In function 'std::vector<int> solve_queries(int, int, std::string&, std::vector<int>&, std::vector<int>&)':
floppy.cpp:30:16: warning: unused variable 'm' [-Wunused-variable]
   30 |     int k = 0, m = bits.size(), jj = 0;
      |                ^
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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccNnNuwW.o: in function `run2()':
stub.cpp:(.text+0x698): undefined reference to `solve_queries(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: /tmp/ccNnNuwW.o: in function `run1()':
stub.cpp:(.text+0xb1d): undefined reference to `read_array(int, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status