답안 #261564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261564 2020-08-11T21:21:51 Z Rouge_Hugo 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
112 ms 19456 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=200009;
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];
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];
    /*if(bo[x]>=3)
        re+=bo[x]*(bo[x]-1)*(bo[x]-2);*/
    re+=2*up*bo[x]*sz[x];
    /*if(bo[x]>2)
    {
        re+=(up)*((bo[x])-1)*((bo[x])-2)*2;
        re+=(sz[x])*(bo[x]-1)*(bo[x]-2)*2;
    }
    re+=(bo[x]-1)*up*2;
    re+=(bo[x]-1)*(sz[x])*2;*/
    for(auto it:v1[x])
    {
        if(it==p)continue;
        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:47: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 20 ms 19456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 19456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 112 ms 16172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 11392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 81 ms 16124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 11392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 84 ms 16124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 19456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 19456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -