제출 #372416

#제출 시각아이디문제언어결과실행 시간메모리
372416MaisyDoge13Traffic (IOI10_traffic)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <cstdio> #include <vector> #include <utility> #include <cmath> #include <algorithm> #include <array> #include <set> #include <climits> #include <map> #include <memory> using namespace std; #define input "problem.in" #define output "problem.out" int n; struct City { int i, p; bool vis=0; vector<pair<int,shared_ptr<City>>> roads; City(int I, int P) { i=I; p=P; } int DFS(int prev=-1) { int added=p; for (int j=0;j<(roads.size());j++) { if (roads[j].second->i==prev) continue; if (roads[j].first==0) { roads[j].first=roads[j].second->DFS(i); } added+=roads[j].first; } return added; } int res() { int res=0; for (int j=0;j<(roads.size());j++) { res=max(roads[j].first, res); } return res; } }; vector<shared_ptr<City>> cities; int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen(input, "r", stdin); //freopen(output, "w", stdout); cin >> n; cities.reserve(n); for (int i=0;i<n;i++) { int p; cin >> p; cities.push_back(make_shared<City>(i, p)); } for (int i=1;i<n;i++) { int a, b; cin >> a >> b; cities[a]->roads.push_back({0,cities[b]}); cities[b]->roads.push_back({0,cities[a]}); } int ans=INT_MAX; int city=0; for (shared_ptr<City> c: cities) { c->DFS(); } for (shared_ptr<City> c: cities) { int res=c->res(); if (res < ans) { ans = res; city=c->i; } } cout << city << endl; }

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

traffic.cpp: In member function 'int City::DFS(int)':
traffic.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::shared_ptr<City> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int j=0;j<(roads.size());j++) {
      |                      ~^~~~~~~~~~~~~~~
traffic.cpp: In member function 'int City::res()':
traffic.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::shared_ptr<City> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int j=0;j<(roads.size());j++) {
      |                      ~^~~~~~~~~~~~~~~
/tmp/ccEqGcsC.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cciXjOl9.o:traffic.cpp:(.text.startup+0x0): first defined here
/tmp/ccEqGcsC.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status