제출 #585027

#제출 시각아이디문제언어결과실행 시간메모리
585027Dan4Life꿈 (IOI13_dreaming)C++17
0 / 100
63 ms24484 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define sz(a) (int)a.size() const int maxn = (int)1e5+10; vector<pair<int,int>> adj[maxn]; set<pair<int,int>> S[maxn]; int vis[maxn], max_dis[maxn], diameter[maxn]; int n, m, root1, root2, cnt = 1; void dfs2(int s, int p){ for(auto c : adj[s]){ int u = c.fi, w = c.se; if(u==p) continue; dfs2(u, s); S[s].insert({max_dis[u]+w, u}); } int tot = 0; if(p!=-1){ auto x = S[p]; for(auto u : x) if(u.se!=s) tot = u.fi; } while(sz(S[s])>2) S[s].erase(S[s].begin()); for(auto u : S[s]) tot = max(tot, u.fi); } void dfs(int s, int p){ vis[s] = cnt; multiset<int> S; S.clear(); for(auto c : adj[s]){ int u = c.fi, w = c.se; if(u==p) continue; dfs(u, s); max_dis[s] = max(max_dis[s], max_dis[u]+w); S.insert(max_dis[u]+w); } while(sz(S)>2) S.erase(S.begin()); int sum = 0; for(auto u : S) sum+=u; diameter[s] = sum; } int diam(int cc){ int ans = 0; for(int i = 1; i <= n; i++) if(vis[i]==cc) ans = max(ans, diameter[i]); return ans; } int path(int cc){ int ans = 0; for(int i = 1; i <= n; i++) if(vis[i]==cc) ans = max(ans, diameter[i]); return ans; } int travelTime(int N, int M, int L, int A[], int B[], int T[]){ n = N, m = M; for(int i = 0; i < M; i++) adj[A[i]].pb({B[i],T[i]}), adj[B[i]].pb({A[i],T[i]}); root1 = 1; dfs(root1,-1); for(int i = 1; i <= N; i++) if(!vis[i]) root2 = i; cnt++; dfs(root2,-1); return max({diam(1), diam(2), path(1)+L+path(2)}); }

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

dreaming.cpp: In function 'void dfs2(int, int)':
dreaming.cpp:18:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   18 |         if(u==p) continue; dfs2(u, s);
      |         ^~
dreaming.cpp:18:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   18 |         if(u==p) continue; dfs2(u, s);
      |                            ^~~~
dreaming.cpp: In function 'void dfs(int, int)':
dreaming.cpp:36:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   36 |         if(u==p) continue; dfs(u, s);
      |         ^~
dreaming.cpp:36:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   36 |         if(u==p) continue; dfs(u, s);
      |                            ^~~
#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...