Submission #758587

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7585872023-06-14 23:40:30KN200711Race (IOI11_race)C++14
100 / 100
433 ms111124 KiB
#include "race.h"
# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
using namespace std;
set< pair<ll, int> > nw[200001];
vector< pair<ll, int> > edge[200001];
int ans = 1e9 + 11;
int KK;
void dfs(int a, int pr, ll v, int c) {
nw[a].insert(make_pair(v, c));
for(int k=0;k<edge[a].size();k++) {
if(edge[a][k].fi == pr) continue;
dfs(edge[a][k].fi, a, v + edge[a][k].se, c+1);
if(nw[edge[a][k].fi].size() > nw[a].size()) swap(nw[a], nw[edge[a][k].fi]);
for(auto p : nw[edge[a][k].fi]) {
auto it = nw[a].lower_bound(make_pair(KK + 2ll * v - p.fi, 0));
if(it == nw[a].end()) continue;
if(it->fi == KK + 2ll * v - p.fi) ans = min(ans, it->se + p.se - 2 * c);
}
for(auto p : nw[edge[a][k].fi]) {
nw[a].insert(p);
}
}
}
int best_path(int N, int K, int H[][2], int L[]) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

race.cpp: In function 'void dfs(int, int, long long int, int)':
race.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int k=0;k<edge[a].size();k++) {
      |              ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...