답안 #393334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393334 2021-04-23T08:08:21 Z parsabahrami 철인 이종 경기 (APIO18_duathlon) C++17
8 / 100
85 ms 9632 KB
    /* There's someone in my head but it's not me */ 
    #include <bits/stdc++.h>
     
    using namespace std;
     
    typedef long long int ll;
    typedef pair<int, int> pii;
     
    #define SZ(x)                       (int) x.size()
    #define F                           first
    #define S                           second
     
    const int N = 1e5 + 10, MOD = 1e9 + 7;
    int s, n, m, M[N], f = 1; vector<int> adj[N];
     
    void DFS(int v) {
        s++;
        M[v] = 1; 
        if (SZ(adj[v]) < 2) f = 0;
        for (int u : adj[v]) 
            if (!M[u]) DFS(u);
    }
     
    int main() {
        scanf("%d%d", &n, &m);
        for (int i = 1; i <= m; i++) {
            int u, v; scanf("%d%d", &u, &v);
            adj[u].push_back(v);
            adj[v].push_back(u); 
            assert(SZ(adj[u]) < 3);
            assert(SZ(adj[v]) < 3);
        }
        ll ret = 0;
        for (int i = 1; i <= n; i++) {
            if (M[i]) continue;
            s = 0, f = 1;
            DFS(i);
            if (f) ret += 1ll * s * (s - 1) * (s - 2);
            else ret += 1ll * s * (s - 1) * (s - 2) / 3;
        }
        printf("%lld\n", ret);
        return 0;
    }

Compilation message

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         scanf("%d%d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~
count_triplets.cpp:27:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |             int u, v; scanf("%d%d", &u, &v);
      |                       ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 5196 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 5196 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 9304 KB Output is correct
2 Correct 68 ms 9208 KB Output is correct
3 Correct 65 ms 7696 KB Output is correct
4 Correct 62 ms 9632 KB Output is correct
5 Correct 59 ms 8468 KB Output is correct
6 Correct 67 ms 8532 KB Output is correct
7 Correct 76 ms 7976 KB Output is correct
8 Correct 85 ms 8268 KB Output is correct
9 Correct 52 ms 7708 KB Output is correct
10 Correct 53 ms 7876 KB Output is correct
11 Correct 44 ms 7056 KB Output is correct
12 Correct 43 ms 6972 KB Output is correct
13 Correct 44 ms 6904 KB Output is correct
14 Correct 63 ms 6824 KB Output is correct
15 Correct 49 ms 6240 KB Output is correct
16 Correct 30 ms 6136 KB Output is correct
17 Correct 4 ms 3020 KB Output is correct
18 Correct 4 ms 3044 KB Output is correct
19 Correct 4 ms 3020 KB Output is correct
20 Correct 4 ms 3020 KB Output is correct
21 Correct 4 ms 3020 KB Output is correct
22 Correct 4 ms 3032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 5196 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 5452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 5196 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 5196 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 5196 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 5196 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -