답안 #261628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261628 2020-08-11T23:02:21 Z Rouge_Hugo 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
2 ms 768 KB
#include<bits/stdc++.h>
#define fi first
#define pb push_back
#define ll long long
using namespace std;
int n,m;
ll re=0;
int szz=0;
const int N=2009;
vector<pair<int,int>>v[N];
vector<int>v1[N];
ll cnt=1,num[N],low[N],bridge[N],b[N],par[N],vis[N],sz[N],bo[N],t[N];
void solve(int x,int p)
{
    vis[x]=1;
    for(auto it:v1[x])
    {
        if(it==p)continue;
        solve(it,x);
        sz[x]+=sz[it];
    }
    sz[x]+=1;bo[x]=1;
}
void go (int x,int p,ll up)
{
    vis[x]=1;
    sz[x]-=bo[x];
    re+=2*up*sz[x];
    for(auto it:v1[x])
    {
        if(it==p)continue;
        re+=2*t[x]*sz[it];
        t[x]+=sz[it];
        go(it,x,up+bo[x]+sz[x]-sz[it]);
    }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    scanf("%d %d", &n, &m);
    for(int i=0;i<m;i++)
    {
        int x,y;cin>>x>>y;
        v1[x].pb(y);
        v1[y].pb(x);
    }
    cnt=n+1;
    for(int i=1;i<cnt;i++)
    {
        if(vis[i])continue;
        solve(i,0);
    }
    re=0;
    memset (vis,0,sizeof vis);
    for(int i=1;i<cnt;i++)
    {
        if(vis[i])continue;
        go(i,0,0);
    }
    cout<<re;
}

Compilation message

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -