답안 #826995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826995 2023-08-16T07:52:16 Z vjudge1 Cats or Dogs (JOI18_catdog) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "catdog.h"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll a[maxN],dp[maxN][3];
vector<ll>g[maxN];
ll ans=0;
void dfs(ll u,ll p=0)
{
    if(a[u]==0)
    {
        dp[u][1]=dp[u][2]=dp[u][0]=0;
    }
    if(a[u]==1)
    {
        dp[u][1]=0;
        dp[u][2]=dp[u][0]=inf;
    }
    if(a[u]==2)
    {
        dp[u][2]=0;
        dp[u][1]=dp[u][0]=inf;
    }
    for(int v:g[u])
    {
        if(v!=p)
        {
            dfs(v,u);
            dp[u][0]+=min({dp[v][0],dp[v][1]+1,dp[v][2]+1});
            dp[u][1]+=min({dp[v][1],dp[v][0],dp[v][2]+1});
            dp[u][2]+=min({dp[v][2],dp[v][0],dp[v][1]+1});
        }
    }
}
void initialize(int n,vector<int> A,vector<int>B)
{
    for(int i=0;i<n-1;i++)
    {
        g[A[i]].pb(B[i]);
        g[B[i]].pb(A[i]);
    }
    for(int i=1;i<=n;i++)
    {
        a[i]=0;
    }
}
ll cat(int v)
{
    a[v]=1;
    ans=0;
    dfs(1);
    return min({dp[1][1],dp[1][0],dp[1][2]});
}
ll dog(int v)
{
    a[v]=2;
    ans=0;
    dfs(1);
    return min({dp[1][1],dp[1][0],dp[1][2]});;
}
ll neighbor(int v)
{
    a[v]=0;
    ans=0;
    dfs(1);
    return min({dp[1][1],dp[1][0],dp[1][2]});
}
/*int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    initialize(5,{1,2,2,4},{2,3,4,5});
    cat(3),dog(5);
    cat(2),dog(1);
    cout << dog(1);
}*/

Compilation message

catdog.cpp:55:4: error: ambiguating new declaration of 'll cat(int)'
   55 | ll cat(int v)
      |    ^~~
In file included from catdog.cpp:2:
catdog.h:6:5: note: old declaration 'int cat(int)'
    6 | int cat(int v);
      |     ^~~
catdog.cpp:62:4: error: ambiguating new declaration of 'll dog(int)'
   62 | ll dog(int v)
      |    ^~~
In file included from catdog.cpp:2:
catdog.h:7:5: note: old declaration 'int dog(int)'
    7 | int dog(int v);
      |     ^~~
catdog.cpp:69:4: error: ambiguating new declaration of 'll neighbor(int)'
   69 | ll neighbor(int v)
      |    ^~~~~~~~
In file included from catdog.cpp:2:
catdog.h:8:5: note: old declaration 'int neighbor(int)'
    8 | int neighbor(int v);
      |     ^~~~~~~~