답안 #864566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864566 2023-10-23T08:51:51 Z vnm06 철인 이종 경기 (APIO18_duathlon) C++14
8 / 100
34 ms 15456 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

long long n, m, brv=0, sumst=0;
bool used[300005];
vector<int> gr[300005];

void dfs(int v)
{
    used[v]=1;
    brv++;
    int brs=gr[v].size();
    sumst+=brs;
    for(int i=0; i<brs; i++)
    {
        if(used[gr[v][i]]) continue;
        dfs(gr[v][i]);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int v, u;
        cin>>v>>u;
        gr[v].push_back(u);
        gr[u].push_back(v);
    }
    long long ans=0;
    for(int i=1; i<=n; i++)
    {
        if(used[i]) continue;
        brv=0;
        sumst=0;
        dfs(i);
        if(sumst==2*brv) ans+=brv*(brv-1)*(brv-2);
        else ans+=brv*(brv-1)*(brv-2)/3;
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 7260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 7260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 15196 KB Output is correct
2 Correct 28 ms 15256 KB Output is correct
3 Correct 26 ms 12824 KB Output is correct
4 Correct 28 ms 15456 KB Output is correct
5 Correct 25 ms 13400 KB Output is correct
6 Correct 26 ms 13396 KB Output is correct
7 Correct 34 ms 13236 KB Output is correct
8 Correct 25 ms 13148 KB Output is correct
9 Correct 25 ms 12372 KB Output is correct
10 Correct 25 ms 12636 KB Output is correct
11 Correct 23 ms 11608 KB Output is correct
12 Correct 21 ms 11424 KB Output is correct
13 Correct 20 ms 11356 KB Output is correct
14 Correct 19 ms 11352 KB Output is correct
15 Correct 15 ms 10840 KB Output is correct
16 Correct 20 ms 10592 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7512 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Correct 2 ms 7516 KB Output is correct
22 Correct 2 ms 7768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 7540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 10588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 7516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 10836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 7260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 7260 KB Output isn't correct
2 Halted 0 ms 0 KB -