#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()
vvi adj;
namespace BCC {
vi tin, low; int timer, pp;
vvi G; vii edges;
void dfs(int u, int p){
tin[u] = low[u] = timer++;
int child = 0;
for(auto v : adj[u]){
if(v == p) continue;
edges.push_back({u, v});
if(tin[v]) low[u] = min(low[u], tin[v]);
else{
dfs(v, p); low[u] = min(low[u], low[v]);
if((p == -1 and child > 0) or (low[v] >= tin[u] and p != -1)){
while(true){
auto [a, b] = edges.back(); edges.pop_back();
G[pp].push_back(a); G[a].push_back(pp);
G[pp].push_back(b); G[b].push_back(pp);
if(a == u and b == v) break;
}
pp++;
}
child++;
}
}
}
void init(int N){
tin.resize(N), low.resize(N);
pp = N; G.resize(2*N+10); dfs(0, -1);
while(!edges.empty()){
auto [a, b] = edges.back(); edges.pop_back();
G[a].push_back(pp); G[pp].push_back(a);
G[b].push_back(pp); G[pp].push_back(b);
}
for(auto &vec : G){
sort(all(vec));
vec.erase(unique(all(vec)), vec.end());
}
}
};
vi sz; int N, ANS = 0;
int comp_sz(int u, int p, auto &G){
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int M; cin >> N >> M;
adj.resize(N);
while(M--){
int u, v; cin >> u >> v;
u--, v--;
adj[u].push_back(v);
adj[v].push_back(u);
}
BCC::init(N);
return 0;
}
Compilation message
count_triplets.cpp:68:27: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
68 | int comp_sz(int u, int p, auto &G){
| ^~~~
count_triplets.cpp: In function 'int comp_sz(int, int, auto:23&)':
count_triplets.cpp:70:1: warning: no return statement in function returning non-void [-Wreturn-type]
70 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
129 ms |
30844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
109 ms |
18888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
107 ms |
18860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |