제출 #152952

#제출 시각아이디문제언어결과실행 시간메모리
152952arnold518철인 이종 경기 (APIO18_duathlon)C++14
23 / 100
1112 ms1048580 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, M; vector<int> adj[MAXN+10]; ll ans=0; int sz[MAXN+10]; bool vis[MAXN+10]; void dfs1(int now, int bef) { sz[now]=1; vis[now]=1; for(int nxt : adj[now]) { if(nxt==bef) continue; dfs1(nxt, now); sz[now]+=sz[nxt]; } } void dfs2(int now, int bef) { int sum=0; for(int nxt : adj[now]) { if(nxt==bef) continue; sz[now]-=sz[nxt]; sz[nxt]+=sz[now]; dfs2(nxt, now); sz[nxt]-=sz[now]; sz[now]+=sz[nxt]; } for(int nxt : adj[now]) { ans-=(ll)sz[nxt]*sz[nxt]; sum+=sz[nxt]; } ans+=(ll)sum*sum; } int main() { int i, j; scanf("%d%d", &N, &M); for(i=1; i<=M; i++) { int u, v; scanf("%d%d", &u, &v); adj[u].push_back(v); adj[v].push_back(u); } for(i=1; i<=N; i++) if(!vis[i]) { dfs1(i, i); dfs2(i, i); } printf("%lld", ans); }

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

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:50:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
count_triplets.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
count_triplets.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~
#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...