답안 #815826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815826 2023-08-09T00:42:04 Z Ozy 철인 이종 경기 (APIO18_duathlon) C++17
8 / 100
44 ms 14108 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define debug(a) cout << #a <<  " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define pll pair<lli,lli> 

#define MAX 100000

lli n,m,a,b,tam,res;
vector<lli> hijos[MAX+2];
lli vis[MAX+2];

bool ciclo(lli pos, lli padre) {
    bool puedo = false;

    tam++;
    vis[pos]=1;
    for(auto h : hijos[pos]) {
        if (h == padre) continue;
        if (vis[h]) {
            puedo = true;
            continue;
        }
        puedo |= ciclo(h,pos);
    }

    return puedo;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;

    rep(i,1,m) {
        cin >> a >> b;
        hijos[a].push_back(b);
        hijos[b].push_back(a);
    }

    rep(i,1,n) {
        if(vis[i]) continue;
        tam = 0;
        if (ciclo(i,0)) a = (tam*(tam-1)*(tam-2));
        else a = (tam*(tam-1)*(tam-2))/3;
        res += a;
    }

    cout << res;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2680 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Incorrect 2 ms 2644 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2680 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Incorrect 2 ms 2644 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 12748 KB Output is correct
2 Correct 41 ms 14108 KB Output is correct
3 Correct 30 ms 10932 KB Output is correct
4 Correct 35 ms 12400 KB Output is correct
5 Correct 30 ms 9860 KB Output is correct
6 Correct 35 ms 9872 KB Output is correct
7 Correct 28 ms 8960 KB Output is correct
8 Correct 37 ms 9464 KB Output is correct
9 Correct 40 ms 8376 KB Output is correct
10 Correct 28 ms 8956 KB Output is correct
11 Correct 23 ms 7512 KB Output is correct
12 Correct 25 ms 7416 KB Output is correct
13 Correct 21 ms 7372 KB Output is correct
14 Correct 21 ms 7176 KB Output is correct
15 Correct 18 ms 6568 KB Output is correct
16 Correct 20 ms 6596 KB Output is correct
17 Correct 2 ms 3412 KB Output is correct
18 Correct 2 ms 3412 KB Output is correct
19 Correct 2 ms 3412 KB Output is correct
20 Correct 2 ms 3412 KB Output is correct
21 Correct 3 ms 3412 KB Output is correct
22 Correct 2 ms 3452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 7184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 7092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2680 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Incorrect 2 ms 2644 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2680 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Incorrect 2 ms 2644 KB Output isn't correct
8 Halted 0 ms 0 KB -