Submission #995692

# Submission time Handle Problem Language Result Execution time Memory
995692 2024-06-09T18:00:48 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, res;
int curr, gres[2005];

void dfs(int node, int tata, vector<bool> vis)
{
    res[curr].push_back(node);
    ///cout << node << ' ';
    vis[node] = 1;
    if(graf[node].size() == 1)
    {
        dfs(graf[node][0], node, vis);
    }
    else
    {
        if(tata == graf[node][0] && !vis[graf[node][1]])
            dfs(graf[node][1], node, vis);
        else if(!vis[graf[node][0]])
            dfs(graf[node][0], tata, vis);
    }
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
    graf.resize(N + 1);
    res.resize(N + 1);
    for(int i = 0; i < M; i++)
    {
        graf[R[i][0]].push_back(R[i][1]);
        graf[R[i][1]].push_back(R[i][0]);
    }

    vector<bool> vis;
    vis.resize(N + 1);
    for(int i = 0; i < N; i++)
    {
        curr = i;
        dfs(i, -1, vis);
        cout << '\n';
    }
    for(int j = 0; j < Q; j++)
    {
        for(int i = 0; i < N; i++)
        {
            if(res[i][G[j] % res[i].size()] == P)
                gres[j]++;
        }
        answer(gres[j]);
    }
}

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

    return 0;
}

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:54:9: error: 'answer' was not declared in this scope
   54 |         answer(gres[j]);
      |         ^~~~~~
garden.cpp: In function 'int main()':
garden.cpp:61:5: error: 'fin' was not declared in this scope; did you mean 'sin'?
   61 |     fin >> N >> M >> P;
      |     ^~~
      |     sin