Submission #998046

# Submission time Handle Problem Language Result Execution time Memory
998046 2024-06-13T08:49:41 Z popu Tropical Garden (IOI11_garden) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define f first
#define s second

using namespace std;

vector<vector<int>> graf, auxgraf;
int p, n, m, v[300005];

void afis()
{
    for(int i = 0; i < 2 * n; i++)
    {
        if(i % 2)
            cout << i / 2 << "' : ";
        else
            cout << i / 2 << " : ";
        if(graf[i].size())
        {
            if(graf[i][0] % 2)
                cout << graf[i][0] / 2 << "'";
            else
                cout << graf[i][0] / 2;
        }
        cout << '\n';
    }
    cout << '\n';
}

int dfs(int node)
{
    if(v[node])
        return v[node];
    if(graf[node].size())
    {
        v[node] = dfs(graf[node][0]);
        if(v[node])
            v[node]++;
        return v[node];
    }
    return 0;
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
    p = P;
    n = N;
    m = M;
    graf.resize(2 * N + 1);
    auxgraf.resize(N + 1);
    for(int i = 0; i < M; i++)
    {
        if(auxgraf[R[i][0]].size() < 2)
            auxgraf[R[i][0]].push_back(R[i][1]);
        if(auxgraf[R[i][1]].size() < 2)
            auxgraf[R[i][1]].push_back(R[i][0]);
    }
    for(int i = 0; i < N; i++)
    {
        if(auxgraf[auxgraf[i][0]][0] == i)
            graf[2 * i].push_back(2 * auxgraf[i][0] + 1);
        else
            graf[2 * i].push_back(2 * auxgraf[i][0]);
        if(auxgraf[i].size() == 2)
        {
            if(auxgraf[auxgraf[i][1]][0] == i)
                graf[2 * i + 1].push_back(2 * auxgraf[i][1] + 1);
            else
                graf[2 * i + 1].push_back(2 * auxgraf[i][1]);
        }
    }
    afis();
    v[P * 2] = 1;
    v[P * 2 + 1] = 1;
    for(int i = 0; i < N; i++)
        v[2 * i] = dfs(2 * i);
    for(int i = 0; i < 2 * N; i++)
    {
        if(i % 2)
            cout << i / 2 << "' " << v[i] << '\n';
        else
            cout << i / 2 << " " << v[i] << '\n';
    }
}

int main()
{
    int N, M, P, R[150005][2], Q, G[2005];
    cin >> N >> M >> P;
    for(int i = 0; i < M; i++)
        cin >> R[i][0] >> R[i][1];
    cin >> Q;
    for(int i = 0; i < Q; i++)
        cin >> G[i];
    count_routes(N, M, P, R, Q, G);

    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccXmnQi0.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cccDW5n2.o:garden.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status