답안 #791479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
791479 2023-07-24T06:54:35 Z ttamx Star Trek (CEOI20_startrek) C++14
23 / 100
35 ms 468 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;
    for(auto v:adj[u]){
        if(v==p)continue;
        res&=dfs(v,u);
    }
    res^=true;
    return res;
}

bool dfs2(int u,int p,int t,bool w){
    bool res=true;
    for(auto v:adj[u]){
        if(v==p)continue;
        res&=dfs2(v,u,t,w);
    }
    if(u==t)res&=w;
    res^=true;
    return res;
}
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)*dfs2(1,1,i,false);
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 24 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 33 ms 376 KB Output is correct
8 Correct 35 ms 408 KB Output is correct
9 Correct 21 ms 340 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 21 ms 388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 33 ms 376 KB Output is correct
8 Correct 35 ms 408 KB Output is correct
9 Correct 21 ms 340 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 21 ms 388 KB Output is correct
12 Runtime error 1 ms 468 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 33 ms 376 KB Output is correct
8 Correct 35 ms 408 KB Output is correct
9 Correct 21 ms 340 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 21 ms 388 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Incorrect 18 ms 340 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 33 ms 376 KB Output is correct
8 Correct 35 ms 408 KB Output is correct
9 Correct 21 ms 340 KB Output is correct
10 Correct 22 ms 340 KB Output is correct
11 Correct 21 ms 388 KB Output is correct
12 Runtime error 1 ms 468 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 24 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -