답안 #995693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995693 2024-06-09T18:03:55 Z popu 열대 식물원 (Tropical Garden) (IOI11_garden) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define f first
#define s second

using namespace std;

ifstream fin("f.in");
ofstream fout("f.out");

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);
    }
    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]++;
        }
        cout << gres[j] << ' ';
    }
}

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/cc6b501X.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc8yE1JW.o:garden.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status