제출 #28806

#제출 시각아이디문제언어결과실행 시간메모리
28806kavun열대 식물원 (Tropical Garden) (IOI11_garden)C++14
49 / 100
11 ms1272 KiB
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> using namespace std; vector <pair<int,int> > adj[2000]; int dfs(int v, int d, int k, int par) { if(d == k) return v; if(adj[v].size() == 1) return dfs(adj[v][0].first,d+1,k,v); else { int mx = 0; int mxver; for(int i = 0; i < adj[v].size(); i++) { int u = adj[v][i].first; int bt = adj[v][i].second; if(u != par) { if(bt > mx) { mx = bt; mxver = u; } } } return dfs(mxver,d+1,k,v); } } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { for(int i = 0; i < M; i++) { int v = R[i][0], u = R[i][1], beauty = M - i; adj[v].push_back(make_pair(u,beauty)); adj[u].push_back(make_pair(v,beauty)); } int res = 0; for(int i = 0; i < N; i++) { if(dfs(i,0,G[0],-1) == P) res++; } for(int i=0; i<Q; i++) answer(res); }

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

garden.cpp: In function 'int dfs(int, int, int, int)':
garden.cpp:19:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < adj[v].size(); i++)
                        ~~^~~~~~~~~~~~~~~
garden.cpp:8:13: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
 int dfs(int v, int d, int k, int par)
             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...