Submission #791462

# Submission time Handle Problem Language Result Execution time Memory
791462 2023-07-24T06:46:30 Z ttamx Star Trek (CEOI20_startrek) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=1005;
const ll mod=1e9+7;

ll binpow(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res*=a,res%=mod;
        a*=a,a%=mod;
        b>>=1;
    }
    return res;
}

int n;
ll d,ans,sum;
vector<int> adj[N];
ll dp[N][2];

bool dfs(int u,int p){
    bool res=true;
    bool ok=true;
    for(auto v:adj[u]){
        if(v==p)continue;
        ok=false;
        res&=dfs(v,u);
    }
    res^=true;
    return res|ok;
}

bool dfs2(int u,int p,int t,bool w){
    bool res=true;
    bool ok=true;
    for(auto v:adj[u]){
        if(v==p)continue;
        ok=false;
        res&=dfs2(v,u,t,w);
    }
    if(u==t){
        ok=false;
        res&=w;
    }
    res^=true;
    return res|ok;
}
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> d;
    for(int i=1;i<n;i++){
        int u,v;
        cin >> u >> v;
        adj[u].emplace_back(v);
        adj[v].emplace_back(u);
    }
    for(int i=1;i<=n;i++)sum+=dfs(i,i);
    for(int i=1;i<=n;i++)ans+=sum*dfs2(1,1,i,true)+(n-sum)*dfs(1,1,i,false);
    cout << ans;
}

Compilation message

startrek.cpp: In function 'int main()':
startrek.cpp:63:75: error: too many arguments to function 'bool dfs(int, int)'
   63 |     for(int i=1;i<=n;i++)ans+=sum*dfs2(1,1,i,true)+(n-sum)*dfs(1,1,i,false);
      |                                                                           ^
startrek.cpp:26:6: note: declared here
   26 | bool dfs(int u,int p){
      |      ^~~