답안 #871580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871580 2023-11-11T06:53:03 Z Trisanu_Das Star Trek (CEOI20_startrek) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int n;
int cnt=0,idx=0,tmp=0;
int pw(int a,int b){
    int ans=1;
    while(b){
        if(b&1){
            ans=ans*a%mod;
        }
        b>>=1;
        a=a*a%mod;
    }
    return ans;
}
vector<vector<int>> adj;
vector<int> dp;
void dfs(int k,int pa){
    bool flag=0;
    for(int j:adj[k]){
        if(j==pa){
            continue;
        }
        dfs(j,k);
        if(dp[j]==0){
            flag=1;
        }
    }
    if(k==idx&&tmp==1){
        flag=1;
    }
    dp[k]=flag;
}
signed main(){
    cin>>n;
    int d;cin>>d;
    if(n==2){
        int p=pw(2,d*2);
        cout<<p<<endl;
        return 0;
    }
    adj.resize(n*2);
    for(int i=1;i<n;i++){
        int a,b;cin>>a>>b;a--;b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        dp.assign(n,-1);
        dfs(i,i);
        if(dp[i]==1){
            cnt++;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        idx=i;
        dp.assign(n,-1);
        tmp=0;
        dfs(0,0);
        if(dp[0]==1){
            ans+=cnt;
        }
        dp.assign(n,-1);
        tmp=1;
        dfs(0,0);
        if(dp[0]==1){
            ans+=n-cnt;
        }
    }
    cout<<ans%mod<<endl;
 
    return 0;

Compilation message

startrek.cpp: In function 'int main()':
startrek.cpp:75:13: error: expected '}' at end of input
   75 |     return 0;
      |             ^
startrek.cpp:36:14: note: to match this '{'
   36 | signed main(){
      |              ^