제출 #991070

#제출 시각아이디문제언어결과실행 시간메모리
991070borisAngelovTraffic (IOI10_traffic)C++17
0 / 100
4 ms31324 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1000005; const long long inf = (1LL << 60); int n; int a[maxn]; vector<int> g[maxn]; long long sum = 0; long long ans = inf; void dfs(int node, int par, int dep) { sum += (1LL * a[node]) * (1LL * dep); for (int i = 0; i < g[node].size(); ++i) { if (g[node][i] != par) { dfs(g[node][i], node, dep + 1); } } } int LocateCentre(int N, int pp[], int S[], int D[]) { n = N; for (int i = 1; i <= n; ++i) { a[i] = pp[i - 1]; if (i == n) { break; } int x = S[i - 1]; int y = D[i - 1]; ++x; ++y; g[x].push_back(y); g[y].push_back(x); } for (int i = 1; i <= n; ++i) { sum = 0; dfs(i, -1, 0); ans = min(ans, sum); } return ans; }

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

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