답안 #844803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844803 2023-09-06T01:18:54 Z irmuun 철인 이종 경기 (APIO18_duathlon) C++17
0 / 100
48 ms 15452 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;
    vector<ll>adj[n+1];
    for(ll i=1;i<=m;i++){
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(m==n-1){
        ll ans=0;
        vector<ll>cnt(n+1,0);
        function <void(ll,ll)> dfs=[&](ll x,ll p){
            cnt[x]=1;
            vector<ll>v;
            for(auto y:adj[x]){
                if(y!=p){
                    dfs(y,x);
                    v.pb(cnt[y]);
                    cnt[x]+=cnt[y];
                }
            }
            v.pb(n-cnt[x]);
            for(auto y:v){
                ans+=(n-1-y)*y;
            }
        };
        dfs(1,-1);
        cout<<ans;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Incorrect 1 ms 600 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 7108 KB Output is correct
2 Correct 44 ms 8528 KB Output is correct
3 Correct 33 ms 8424 KB Output is correct
4 Correct 33 ms 8424 KB Output is correct
5 Correct 38 ms 8528 KB Output is correct
6 Correct 38 ms 15452 KB Output is correct
7 Correct 44 ms 13468 KB Output is correct
8 Correct 43 ms 12372 KB Output is correct
9 Correct 34 ms 11080 KB Output is correct
10 Incorrect 23 ms 7772 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 7140 KB Output is correct
2 Correct 32 ms 8284 KB Output is correct
3 Incorrect 31 ms 8276 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -