#include<bits/stdc++.h>
using namespace std;
const int maxn=200000+10;
vector<int>adj[maxn],fakeadj[maxn],unnow;
int n,m,vis[maxn],high[maxn],sz[maxn],newnode,low[maxn],wh[maxn],timea;
void vorod(){
cin>>n>>m;
for(int i=0;i<m;i++){
int u,v;
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
}
}
void predfs(int u){
if(vis[u]==1){
return ;
}
vis[u]=1;
timea++;
wh[u]=low[u]=timea;
unnow.push_back(u);
for(auto x:adj[u]){
if(vis[x]){
low[u]=min(low[u],wh[x]);
}else{
predfs(x);
low[u]=min(low[u],low[x]);
if(low[x]>=wh[u]){
// cout<<"wtf: "<<u<<" "<<x<<endl;
fakeadj[u].push_back(newnode);
while((int)fakeadj[newnode].size()==0||fakeadj[newnode].back()!=x){
fakeadj[newnode].push_back(unnow.back());
unnow.pop_back();
}
newnode++;
}
}
}
//cout<<"magemishe: "<<u<<" "<<wh[u]<<" "<<low[u]<<endl;
}
void pre(){
newnode=n+1;
for(int i=1;i<=n;i++){
if(vis[i]==0){
predfs(i);
}
}
for(int i=1;i<=n;i++){
vis[i]=0;
}
}
long long mainres=0;
void dfssolve(int u){
vis[u]=1;
sz[u]=(u<=n);
for(auto x:fakeadj[u]){
dfssolve(x);
sz[u]+=sz[x];
if(u>n){
mainres-=sz[x]*(sz[x]-1)*((int)fakeadj[u].size());
}
}
if(u>n){
mainres-=(int)fakeadj[u].size()*(n-sz[u])*(n-sz[u]-1);
}
//cout<<u<<" "<<sz[u]<<" "<<(int)fakeadj[u].size()<<endl;
}
void solve(){
mainres=n*(n-1)*(n-2);
for(int i=1;i<=n;i++){
if(vis[i]==0){
dfssolve(i);
}
}
cout<<mainres<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vorod();
pre();
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
13400 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
13400 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
27028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13660 KB |
Output is correct |
2 |
Correct |
2 ms |
13660 KB |
Output is correct |
3 |
Correct |
2 ms |
13660 KB |
Output is correct |
4 |
Correct |
3 ms |
13660 KB |
Output is correct |
5 |
Correct |
2 ms |
13660 KB |
Output is correct |
6 |
Correct |
3 ms |
13660 KB |
Output is correct |
7 |
Correct |
2 ms |
13660 KB |
Output is correct |
8 |
Correct |
2 ms |
13552 KB |
Output is correct |
9 |
Correct |
3 ms |
13736 KB |
Output is correct |
10 |
Incorrect |
2 ms |
13660 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
22988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
13660 KB |
Output is correct |
2 |
Correct |
2 ms |
13660 KB |
Output is correct |
3 |
Correct |
2 ms |
13660 KB |
Output is correct |
4 |
Correct |
3 ms |
13656 KB |
Output is correct |
5 |
Correct |
3 ms |
13596 KB |
Output is correct |
6 |
Correct |
2 ms |
13404 KB |
Output is correct |
7 |
Correct |
2 ms |
13592 KB |
Output is correct |
8 |
Correct |
2 ms |
13660 KB |
Output is correct |
9 |
Correct |
2 ms |
13404 KB |
Output is correct |
10 |
Correct |
2 ms |
13660 KB |
Output is correct |
11 |
Correct |
2 ms |
13656 KB |
Output is correct |
12 |
Correct |
3 ms |
13660 KB |
Output is correct |
13 |
Correct |
3 ms |
13552 KB |
Output is correct |
14 |
Correct |
2 ms |
13660 KB |
Output is correct |
15 |
Correct |
3 ms |
13656 KB |
Output is correct |
16 |
Incorrect |
2 ms |
13660 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
22844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
13400 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
13400 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |