제출 #824216

#제출 시각아이디문제언어결과실행 시간메모리
824216Mouad_ouj경주 (Race) (IOI11_race)C++17
21 / 100
3070 ms8088 KiB
#include<bits/stdc++.h> using namespace std; int ans=1000001,n,k; vector<vector< pair<int,int>> > tree; void dfs(int node,int par,int dis,int cur) { for(int x=0;x<tree[node].size();x++) { int to=tree[node][x].first; if(par==to)continue; if(dis+tree[node][x].second>k) continue; if(dis+tree[node][x].second==k) { ans=min(ans,cur+1); continue; } dfs(to,node,dis+tree[node][x].second,cur+1); } } int best_path(int N,int K,int bet[][2],int w[]) { n=N; k=K; tree.resize(n+1); for(int x=0;x<n-1;x++) { tree[bet[x][0]].push_back(make_pair(bet[x][1],w[x])); tree[bet[x][1]].push_back(make_pair(bet[x][0],w[x])); } for(int x=0;x<n;x++) dfs(x,-1,0,0); if(ans!=1000001) return ans; return -1; }

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

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