제출 #559769

#제출 시각아이디문제언어결과실행 시간메모리
559769GioChkhaidze철인 이종 경기 (APIO18_duathlon)C++14
100 / 100
133 ms40100 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; const int N = 2e5 + 5; bool us[N]; ll nds, ans; int n, m, cmp, timer; int disc[N], low[N], sz[N + N + N]; vector < int > rec, v[N], gr[N + N + N]; void dfs(int x, int p) { ++nds; rec.pb(x); us[x] = true; disc[x] = low[x] = ++timer; for (int i = 0; i < v[x].size(); ++i) { int to = v[x][i]; if (to == p) continue; if (!us[to]) { dfs(to, x); low[x] = min(low[x], low[to]); if (low[to] >= disc[x]) { ++cmp; gr[x].pb(cmp + n); while (true) { int nd = rec.back(); rec.pop_back(); gr[cmp + n].pb(nd); if (nd == to) break; } } } else { low[x] = min(low[x], disc[to]); } } } void slv(int x, int p) { sz[x] = (x <= n); ll grs = gr[x].size(); for (int i = 0; i < grs; ++i) { int to = gr[x][i]; slv(to, x); sz[x] += sz[to]; if (x > n) ans -= grs * sz[to] * (sz[to] - 1); } if (x > n) ans -= grs * (nds - sz[x]) * (nds - sz[x] - 1); } main () { ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> n >> m; for (int i = 1; i <= m; ++i) { int a, b; cin >> a >> b; v[a].pb(b); v[b].pb(a); } for (int i = 1; i <= n; ++i) { if (!us[i]) { nds = 0; dfs(i, -1); ans += nds * (nds - 1) * (nds - 2); slv(i, -1); } } cout << ans << "\n"; }

컴파일 시 표준 에러 (stderr) 메시지

count_triplets.cpp: In function 'void dfs(int, int)':
count_triplets.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (int i = 0; i < v[x].size(); ++i) {
      |                  ~~^~~~~~~~~~~~~
count_triplets.cpp: At global scope:
count_triplets.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...