제출 #49594

#제출 시각아이디문제언어결과실행 시간메모리
49594mohammad_kilani철인 이종 경기 (APIO18_duathlon)C++17
0 / 100
1089 ms9956 KiB
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define oo 200000000 const int N = 100010; const int M = 100010; int n , m ,comp[N] , num[N] , comp_cnt = 0 , u , v , dfs_cnt = 0 , dfs_low[N] , dfs_num[N] , num1[N] , num2[N] , tmp[N] , num3[N] , tmp2[N] , s = 0; bool vis[N] ; long long all = 0 , ans = 0, all2 = 0; vector< int > g[N] ; void DFS1(int node){ comp[node] = comp_cnt; num[comp_cnt]++; vis[node] = true; for(int i=0;i<g[node].size();i++){ if(vis[g[node][i]] == false) DFS1(g[node][i]); } } void DFS(int node, int prnt){ dfs_low[node] = dfs_num[node] = dfs_cnt++; num1[node] = 1; num2[node] = 1; tmp[node] = num[comp[node]] - 1; vis[node] = true; for(int i=0;i<g[node].size();i++){ if(g[node][i] == prnt) continue; if(vis[g[node][i]]){ dfs_low[node] = min(dfs_low[node],dfs_num[g[node][i]]); continue; } DFS(g[node][i],node); dfs_low[node] = min(dfs_low[node],dfs_low[g[node][i]]); num1[node] += num1[g[node][i]]; if(dfs_low[g[node][i]] == dfs_num[node]){ ans += (long long)num2[g[node][i]] * (num2[g[node][i]] + 1) * (num2[g[node][i]] - 1); all -= (long long)num2[g[node][i]] * (num2[g[node][i]] + 1) * (num2[g[node][i]] - 1) / 6; tmp[node] -= num1[g[node][i]]; ans += (long long)tmp[node] * num1[g[node][i]] * 2; all -= (long long)tmp[node] * num1[g[node][i]]; } else if(dfs_low[g[node][i]] < dfs_num[node]){ num2[node] += num2[g[node][i]]; } else{ tmp[node] -= num1[g[node][i]]; ans += (long long)tmp[node] * num1[g[node][i]] * 2; all -= (long long)tmp[node] * num1[g[node][i]]; } } } int needed , cant , vis2[N] , vi = 0; bool DFS2(int node){ if(vis2[node] == vi || node == cant) return false; if(node == needed) return true; vis2[node] = vi; for(int i=0;i<g[node].size();i++){ if(DFS2(g[node][i])) return true; } return false; } int main() { scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ scanf("%d%d",&u,&v); g[u].push_back(v); g[v].push_back(u); } all = (long long)n * (n - 1) * (n - 2) / 6; for(int i=1;i<=n;i++){ if(vis[i] == false){ DFS1(i); comp_cnt++; } } for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ for(int k=j+1;k<=n;k++){ for(int l=1;l<=n;l++){ if(l == i || l == j || l == k) continue; cant = l; needed = j; vi++; if(DFS2(i)) continue; vi++; if(DFS2(k)) continue; needed = i; vi++; if(DFS2(j)) continue; vi++; if(DFS2(k)) continue; needed = k; vi++; if(DFS2(i)) continue; vi++; if(DFS2(j)) continue; all--; } } } } memset(vis,0,sizeof(vis)); for(int i=1;i<=n;i++){ if(vis[i] == false) DFS(i,-1); } ans += (long long)all * 4; cout << ans << endl; return 0; }

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

count_triplets.cpp: In function 'void DFS1(int)':
count_triplets.cpp:16:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g[node].size();i++){
                 ~^~~~~~~~~~~~~~~
count_triplets.cpp: In function 'void DFS(int, int)':
count_triplets.cpp:28:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g[node].size();i++){
                 ~^~~~~~~~~~~~~~~
count_triplets.cpp: In function 'bool DFS2(int)':
count_triplets.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g[node].size();i++){
                 ~^~~~~~~~~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:71: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:73: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...