답안 #527265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527265 2022-02-17T04:36:27 Z ecxx Pipes (CEOI15_pipes) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;

int* depth;
int* low;
int* pos = new int[MAXN];
int* edgelist;

void AP(int i, int d, int pa) {
    depth[i] = d; low[i] = d;
    int paedges = 0;
    for (int k = pos[i]; k < pos[i+1]; k++) {
        ch = edgelist[k];
        if (ch==pa) {
            paedges++;
            continue;
        }
        if (depth[ch] != UINT16_MAX) {
            low[i] = min(low[i], depth[ch]);
        } else {
            AP(ch, d+1, i);
            low[i] = min(low[i], low[ch]);
        }
    }
    if (pa==-1) return;
    if (low[i] > depth[pa] && paedges == 1) {
        cout << i+1 << " " << pa+1 << "\n";
    }
}

int main() {

    int N, M, a, b; cin >> N >> M;
    vector<pair<int, int> > EL(2*M, {0, 0});

    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        EL[2*i] = {a,b};
        EL[2*i+1] = {b,a};
    }

    sort(EL.begin(), EL.end());

    int curri = -1;
    int ptr = 0;
    int q = 0;

    edgelist = new int[2*M+5];

    for (auto a : EL) {
        if (a.first != curri) { 
            pos[ptr++] = q;
            curri = a.first;
        }
        edgelist[q] = a.second;
        q++;
    }

    vector<int>().swap(EL);

}

Compilation message

pipes.cpp: In function 'void AP(int, int, int)':
pipes.cpp:14:9: error: 'ch' was not declared in this scope
   14 |         ch = edgelist[k];
      |         ^~
pipes.cpp: In function 'int main()':
pipes.cpp:60:24: error: cannot convert 'std::vector<std::pair<int, int> >' to 'std::vector<int>&'
   60 |     vector<int>().swap(EL);
      |                        ^~
      |                        |
      |                        std::vector<std::pair<int, int> >
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from pipes.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1480:20: note:   initializing argument 1 of 'void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
 1480 |       swap(vector& __x) _GLIBCXX_NOEXCEPT
      |            ~~~~~~~~^~~