답안 #980788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980788 2024-05-12T12:04:15 Z Unforgettablepl 철인 이종 경기 (APIO18_duathlon) C++17
0 / 100
38 ms 20560 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

vector<int> adj[200001];
bool visited[200001];
int DP[200001][4];
bool isCycle;
int tot;

void dfs(int x,int p){
    if(visited[x]){
        isCycle=true;
        return;
    }
    tot++;
    visited[x]=true;
    for(int&i:adj[x])if(i!=p)dfs(i,x);
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for(auto&i:DP)i[0]=1;
    for(int i=1;i<=200000;i++)for(int j=1;j<=3;j++)DP[i][j]=DP[i-1][j]+DP[i-1][j-1];
    int n,m;
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        int a,b;cin>>a>>b;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
    }
    int ans = 0;
    for(int i=1;i<=n;i++)if(!visited[i]){
        isCycle = false;
        tot = 0;
        dfs(i,0);
        if(isCycle)ans+=tot*(tot-1)*(tot-2);
        else ans+=DP[tot][3];
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11612 KB Output is correct
2 Correct 3 ms 11612 KB Output is correct
3 Correct 3 ms 11612 KB Output is correct
4 Correct 3 ms 11864 KB Output is correct
5 Correct 3 ms 11608 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Incorrect 3 ms 11864 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11612 KB Output is correct
2 Correct 3 ms 11612 KB Output is correct
3 Correct 3 ms 11612 KB Output is correct
4 Correct 3 ms 11864 KB Output is correct
5 Correct 3 ms 11608 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Incorrect 3 ms 11864 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 20004 KB Output is correct
2 Correct 33 ms 20560 KB Output is correct
3 Incorrect 38 ms 18236 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 11612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 15184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 11612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 15196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11612 KB Output is correct
2 Correct 3 ms 11612 KB Output is correct
3 Correct 3 ms 11612 KB Output is correct
4 Correct 3 ms 11864 KB Output is correct
5 Correct 3 ms 11608 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Incorrect 3 ms 11864 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11612 KB Output is correct
2 Correct 3 ms 11612 KB Output is correct
3 Correct 3 ms 11612 KB Output is correct
4 Correct 3 ms 11864 KB Output is correct
5 Correct 3 ms 11608 KB Output is correct
6 Correct 3 ms 11356 KB Output is correct
7 Incorrect 3 ms 11864 KB Output isn't correct
8 Halted 0 ms 0 KB -