제출 #347930

#제출 시각아이디문제언어결과실행 시간메모리
347930training4usacoTraffic (IOI10_traffic)C++11
0 / 100
2 ms492 KiB
#include "traffic.h" #include <climits> #include <iostream> #include <vector> using namespace std; int n; vector<int> p; vector<vector<int>> adj; vector<int> traffic; vector<int> children; int numFans = 0; void dfs (int idx, int par) { for (int i = 0; i < adj[idx].size(); ++i) { if (adj[idx][i] == par) { continue; } dfs(adj[idx][i], idx); children[idx] += children[adj[idx][i]]; traffic[idx] = max(traffic[idx], children[adj[idx][i]]); } traffic[idx] = max(traffic[idx], numFans - children[idx] - p[idx]); children[idx] += p[idx]; } int LocateCentre (int ni, int pi[], int d[], int s[]) { n = ni; for(int i = 0; i < n; ++i) { p[i] = pi[i]; } adj = vector<vector<int>>(n); traffic = vector<int>(n); children = vector<int>(n); for (int i = 0; i < n; i++) { numFans += p[i]; } for (int i = 0; i < n - 1; i++) { adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } dfs(0, -1); int best = INT_MAX; int ans = -1; for (int i = 0; i < n; i++) { if (traffic[i] < best) { ans = i; best = traffic[i]; } } return ans; }

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

traffic.cpp: In function 'void dfs(int, int)':
traffic.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < adj[idx].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...