Submission #1283159

#TimeUsernameProblemLanguageResultExecution timeMemory
1283159abc123Alice, Bob, and Circuit (APIO23_abc)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Edge {
    int t, x, y;
};

struct Query {
    int a, b, p, idx;
};

vector<int> par;

int find(int x) {
    if (par[x] != x) par[x] = find(par[x]);
    return par[x];
}

void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x != y) par[x] = y;
}

int main() {
    int N, M, U;
    cin >> N >> M >> U;
    vector<Edge> edges(M);
    for (int i = 0; i < M; ++i)
        cin >> edges[i].x >> edges[i].y >> edges[i].t;

    vector<Query> queries(U);
    for (int i = 0; i < U; ++i) {
        cin >> queries[i].a >> queries[i].b >> queries[i].p;
        queries[i].idx = i; // preserve order
    }
    sort(edges.begin(), edges.end(), [](Edge a, Edge b){ return a.t < b.t; });
    sort(queries.begin(), queries.end(), [](Query a, Query b){ return a.p < b.p; });

    par.resize(N + 1);
    for (int i = 1; i <= N; ++i) par[i] = i;

    vector<string> answer(U);
    int edge_i = 0;
    for (const auto& q : queries) {
        // Activate all roads <= current p
        while (edge_i < M && edges[edge_i].t <= q.p) {
            unite(edges[edge_i].x, edges[edge_i].y);
            ++edge_i;
        }
        if (find(q.a) == find(q.b)) answer[q.idx] = "TAIP";
        else answer[q.idx] = "NE";
    }
    for (auto& ans : answer) cout << ans << '\n';
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cciIXElD.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJtyCaD.o:abc.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cciIXElD.o: in function `int grader_entry<bob()::{lambda(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&)#1}>(bob()::{lambda(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&)#1} const&) [clone .isra.0]':
stub.cpp:(.text+0x6ee): undefined reference to `bob(int, char const (*) [5], char const (*) [5], bool*)'
/usr/bin/ld: /tmp/cciIXElD.o: in function `int grader_entry<alice()::{lambda(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&)#1}>(alice()::{lambda(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&)#1} const&) [clone .isra.0]':
stub.cpp:(.text+0xb8d): undefined reference to `alice(int, char const (*) [5], unsigned short const*, bool*)'
/usr/bin/ld: /tmp/cciIXElD.o: in function `int grader_entry<circuit()::{lambda(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&)#1}>(circuit()::{lambda(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&)#1} const&) [clone .isra.0]':
stub.cpp:(.text+0x122b): undefined reference to `circuit(int, int, int*, int (*) [2], int (*) [16])'
collect2: error: ld returned 1 exit status