답안 #543317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
543317 2022-03-30T07:46:51 Z AmirElarbi 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ii pair<int,int>
#define ve vector
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define fi first
#define MAX_N 500000
#define se second
#define eps 1e-7
#define INF 1e7
#define ll long long
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int nax = 3e5+5;
using namespace std;
int n,m,p,q, aff = 0, cur,res,c1 = INF, c2 = INF;
vi rev[nax];
bool vis[nax];
int adj[nax], f1[nax], f2[nax];
void dfs(int u, int d){
    if(vis[u] && u == p){
        c1 = d;
        return;
    } else if(vis[u])
        return;
    f1[u] = d;
    vis[u] = 1;
    for(auto x : rev[u])
        dfs(x,d+1);
}
void dfs2(int u, int d){
    if(vis[u] && u == p+n){
        c2 = d;
        return;
    } else if(vis[u])
        return;
    f2[u] = d, vis[u] = 1;
    for(auto x : rev[u])
        dfs2(x,d+1);
}
int main(){
    optimise;
    cin >> n >> m >> p;
    memset(adj,-1,sizeof adj);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        if(adj[a] == -1) {
            if(adj[b] != -1){
                adj[a] = b;
                if(adj[b+n] == -1) adj[b+n] = a+n;
            } else {
                adj[a] = b+n, adj[b] = a+n;
            }
        } else if(adj[a+n] == -1){
            if(adj[b] != -1){
                adj[a+n] = b;
                if(adj[b+n] == -1) adj[b+n] = a;
            } else {
                adj[a+n] = b+n, adj[b] = a;
            }
        } else {
            if(adj[b] != -1){
                if(adj[b+n] == -1)
                    adj[b+n] = a;
            } else {
                adj[b] = a;
            }
        }
    }
    for (int i = 0; i < 2*n; ++i)
        f1[i] = INF, f2[i] = INF;
    for (int i = 0; i < n; ++i)
    {
        if(adj[i+n] == -1) adj[i+n] = adj[i];
    }
    for (int i = 0; i < 2*n; ++i)
    {
        rev[adj[i]].pb(i);
    }
    dfs(p,0);
    memset(vis,0,sizeof vis);
    dfs2(p+n,0);
    cin >> q;
    while(q--){
        aff = 0;
        cin >> cur;
        for (int j = 0; j < n; ++j)
        {
            if(c1 != INF && cur >= f1[j] && (cur-f1[j])%c1 == 0) aff++;
            else if(c2 != INF && cur >= f2[j]  && (cur-f2[j])%c2 == 0) aff++;
            else if(cur == f1[j]) aff++;
            else if(cur == f2[j]) aff++;
        }
        cout << aff << " ";
    }
}

Compilation message

/usr/bin/ld: /tmp/ccwLhYuQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cct8c5lP.o:garden.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccwLhYuQ.o: in function `main':
grader.cpp:(.text.startup+0x3f): undefined reference to `count_routes(int, int, int, int (*) [2], int, int*)'
collect2: error: ld returned 1 exit status