답안 #486428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486428 2021-11-11T16:29:38 Z blue Construction of Highway (JOI18_construction) C++17
컴파일 오류
0 ms 0 KB

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int N;
    cin >> N;

    int C[1+N];
    for(int i = 1; i <= N; i++) cin >> C[i];

    int P[1+N];
    P[0] = P[1] = 0;

    for(int j = 1; j <= N-1; j++)
    {
        vector<int> lst;

        int A, B;
        cin >> A >> B;

        for(int q = A; q != 0; q = P[q])
            lst.push_back(C[q]);

        reverse(lst.begin(), lst.end());

        int ans = 0;

        for(int i = 0; i < int(lst.size()); i++)
            for(int j = i+1; j < int(lst.size()); j++)
                ans += lst[i] > lst[j];

        cout << ans << '\n';

        for(int k = A; k != 0; k = P[k])
            C[k] = C[B];

        P[B] = A;
    }
}

Compilation message

construction.cpp: In function 'int main()':
construction.cpp:28:9: error: 'reverse' was not declared in this scope
   28 |         reverse(lst.begin(), lst.end());
      |         ^~~~~~~