Submission #96749

#TimeUsernameProblemLanguageResultExecution timeMemory
96749figter001Dreaming (IOI13_dreaming)C++14
47 / 100
158 ms11044 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5; vector<pair<int,int>> g[maxn]; vector<int> C; int mx,to,cst[maxn],t,best,mn,vis[maxn],c; void path(int u,int cost){ vis[u] = c; if(cost > mx){ mx = cost; to = u; } for(pair<int,int> cur : g[u]){ int v = cur.first; int w = cur.second; if(vis[v] == c)continue; path(v,cost + w); } } void dfs(int u,int cost){ vis[u] = c; if(t == 1){ cst[u] = max(cst[u],cost); if(cst[u] < mn){ mn = cst[u]; best = u; } }else cst[u] = cost; for(pair<int,int> cur : g[u]){ int v = cur.first; int w = cur.second; if(vis[v] == c)continue; dfs(v,cost + w); } } void find(int s){ mn = 2e9; mx = -1; c++; path(s,0); int a = to; c++; mx = -1; path(a,0); int b = to; t = 0; c++; dfs(a,0); t = 1; c++; dfs(b,0); C.push_back(best); } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for(int i=0;i<M;i++){ g[A[i]].push_back({B[i],T[i]}); g[B[i]].push_back({A[i],T[i]}); } for(int i=0;i<N;i++) if(!vis[i]) find(i); for(int i=1;i<C.size();i++){ g[C[i]].push_back({C[0],L}); g[C[0]].push_back({C[i],L}); } c++; mx = -1; path(0,0); c++; mx = -1; path(to,0); return mx; }

Compilation message (stderr)

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:71:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<C.size();i++){
              ~^~~~~~~~~
#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...