답안 #204724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
204724 2020-02-26T18:46:56 Z Kastanda Bubble Sort 2 (JOI18_bubblesort2) C++11
컴파일 오류
0 ms 0 KB
// In The Name Of The Queen
#include<bits/stdc++.h>
#include "bubblesort2.h"
using namespace std;
const int N = 500005, MXS = N * 2 * 4;
int n, q, MX[MXS], LZ[MXS];
vector < pair < int , int > > U;
void Add(int le, int ri, int val, int id = 1, int l = 0, int r = (int)U.size())
{
    if (ri <= l || r <= le)
        return ;
    if (le <= l && r <= ri)
    {
        MX[id] += val;
        LZ[id] += val;
        return ;
    }
    Add(le, ri, val, lc, l, md);
    Add(le, ri, val, rc, md, r);
    MX[id] = max(MX[lc], MX[rc]) + LZ[id];
}
vector < int > countScans(vector < int > A, vector < int > X, vector < int > V)
{
    n = (int)A.size();
    q = (int)X.size();
    for (int i = 0; i < n; i ++)
        U.push_back({A[i], i});
    for (int i = 0; i < q; i ++)
        U.push_back({V[i], X[i]});
    sort(U.begin(), U.end());
    U.resize(unique(U.begin(), U.end()) - U.begin());

    auto GetId = [&] (pair < int , int > val) {
        return (int)(lower_bound(U.begin(), U.end(), val) - U.begin());
    };

    auto Apply = [&] (int i, int val) {
        int p = GetId({A[i], i});
        Add(p, p + 1, i * val);
        int l = GetId({A[i], -1});
        Add(l, (int)U.size(), val);
    };

    for (int i = 0; i < n; i ++)
        Apply(i, 1);
    vector < int > R;
    for (int i = 0; i < q; i ++)
    {
        Apply(X[i], -1);
        A[X[i]] = V[i];
        Apply(X[i], 1);
        R.push_back(MX[1]);
    }
    return (R);
}

Compilation message

bubblesort2.cpp: In function 'void Add(int, int, int, int, int, int)':
bubblesort2.cpp:18:22: error: 'lc' was not declared in this scope
     Add(le, ri, val, lc, l, md);
                      ^~
bubblesort2.cpp:18:22: note: suggested alternative: 'le'
     Add(le, ri, val, lc, l, md);
                      ^~
                      le
bubblesort2.cpp:18:29: error: 'md' was not declared in this scope
     Add(le, ri, val, lc, l, md);
                             ^~
bubblesort2.cpp:18:29: note: suggested alternative: 'id'
     Add(le, ri, val, lc, l, md);
                             ^~
                             id
bubblesort2.cpp:19:22: error: 'rc' was not declared in this scope
     Add(le, ri, val, rc, md, r);
                      ^~
bubblesort2.cpp:19:22: note: suggested alternative: 'ri'
     Add(le, ri, val, rc, md, r);
                      ^~
                      ri