제출 #567182

#제출 시각아이디문제언어결과실행 시간메모리
567182Mahdi철인 이종 경기 (APIO18_duathlon)C++17
8 / 100
63 ms10228 KiB
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define all(v) v.begin(), v.end() #define F first #define S second typedef long long ll; typedef pair<int, int> pii; typedef pair<int, ll>pil; const int N=1e5+5; int n, m, nn; vector<int>g[N], nd; bool mk[N]; void dfs(const int &v){ mk[v]=1; nd.push_back(v); for(int u: g[v]){ if(!mk[u]) dfs(u); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; if(m>n) return 0; for(int i=0;i<m;++i){ int u, v; cin>>u>>v; g[--u].push_back(--v); g[v].push_back(u); } ll ans=0; for(int i=0;i<n;++i){ if(!mk[i]){ dfs(i); nn=nd.size(); bool b=1; for(int v: nd){ if(g[v].size()==1){ b=0; break; } } if(b) ans+=1LL*nn*(nn-1)*(nn-2); else ans+=1LL*nn*(nn-1)*(nn-2)/3; nd.clear(); } } cout<<ans<<'\n'; }
#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...