답안 #698772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
698772 2023-02-14T09:37:35 Z vjudge1 철인 이종 경기 (APIO18_duathlon) C++17
0 / 100
23 ms 1920 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int M = 1e4+5, K = 4e2+2, MOD = 1e9+7;
vector<int> node[M];
bitset<10005> vis;
int dist[M];

void dfs(int s, int p = 0) {
    if (!p) p = s, vis = 0, dist[s] = 0;
    dist[s] = dist[p] + 1;
    vis[s] = true;
    for (int i:node[s])
        if (!vis[i]) dfs(i, s);
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        node[a].push_back(b);
        node[b].push_back(a);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        dfs(i);
        for (int j = 1; j <= n; j++) {
            ans += max(dist[j]-2, 0ll);
        }
    } cout << ans << endl;

    return 0;
}
/*
1 2 3 4 5 6 7 8
1 2 2 4 5 6 7 8
3
SRS RR SRRRS RRRR
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
------
2 1 3
1 1 1 4
1 1 2 5
1 3
1 5
1 7
------
1 1 1
100000000 1 1 1
1 1
------
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 644 KB Output is correct
2 Correct 17 ms 596 KB Output is correct
3 Correct 14 ms 596 KB Output is correct
4 Correct 23 ms 1876 KB Output is correct
5 Correct 18 ms 1364 KB Output is correct
6 Correct 18 ms 1260 KB Output is correct
7 Correct 23 ms 1920 KB Output is correct
8 Correct 17 ms 1364 KB Output is correct
9 Correct 17 ms 1236 KB Output is correct
10 Incorrect 11 ms 632 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 628 KB Output is correct
2 Correct 14 ms 596 KB Output is correct
3 Incorrect 17 ms 596 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -