제출 #415750

#제출 시각아이디문제언어결과실행 시간메모리
415750Emin2004Dreaming (IOI13_dreaming)C++14
18 / 100
100 ms13772 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int, int> #define F first #define S second const int N = 100005; int used[N]; int dis[N][2]; vector <pii> v[N]; vector <int> vis; void DFS(int node, int r){ used[node] = 1; vis.pb(node); for(pii i : v[node]){ if(!used[i.F]){ used[i.F] = 1; dis[i.F][r] = dis[node][r] + i.S; DFS(i.F, r); } } } int travelTime(int n, int m, int l, int a[], int b[], int t[]) { // return n; if(n == 1) return 0; for(int i = 0; i < m; i++){ v[a[i]].pb({b[i], t[i]}); v[b[i]].pb({a[i], t[i]}); } vector<int> results; for(int i = 0; i < n; i++){ if(!used[i]) { DFS(i,0); int mx = 0, dd; for(int j : vis){ used[j] = 0; if(dis[j][0] >= mx) { mx = dis[j][0]; dd = j; } dis[j][0] = 0; } vis.clear(); DFS(dd, 0); mx = 0; for(int j : vis){ used[j] = 0; if(dis[j][0] >= mx) { mx = dis[j][0]; dd = j; } } vis.clear(); DFS(dd, 1); for(int j : vis){ mx = min(mx, max(dis[j][0], dis[j][1])); dis[j][0] = 0; dis[j][1] = 0; } vis.clear(); results.pb(mx); // return mx; } } sort(results.begin(), results.end()); int sz = results.size(); int ans = results[sz - 1]; if(sz >= 2) ans += results[sz - 2] + l; if(sz >= 3) ans = max(ans, results[sz - 2] + results[sz - 3] + l + l); return ans; }

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

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:51:16: warning: 'dd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |             DFS(dd, 0);
      |             ~~~^~~~~~~
#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...