제출 #335890

#제출 시각아이디문제언어결과실행 시간메모리
335890saarang123꿈 (IOI13_dreaming)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "dreaming.h" using namespace std; using ll = long long; const int N = 1e5 + 2; vector<array<ll, 2>> g[N]; bool vis[N]; array<ll, 2> par[N]; vector<array<ll, 2>> cost; array<ll, 2> dfs(ll v, ll p, ll d) { vis[v] = true; par[v] = {p, d}; array<ll, 2> ret = {d, v}; for(auto tx : g[v]) { ll u = tx[0], w = tx[1]; if(u == p) continue; ret = max(ret, dfs(u, v, d + w)); } return ret; } ll travelTime(ll N, ll M, ll L, ll A[], ll B[], ll T[]) { for(ll i = 0; i < M; i++) { g[A[i]].push_back({B[i], T[i]}); g[B[i]].push_back({A[i], T[i]}); } for(ll i = 0; i < N; i++) { if(vis[i]) continue; array<ll, 2> x = dfs(i, -1, 0); array<ll, 2> d = dfs(x[1], -1, 0); array<ll, 2> v = {d[1], d[0]}; array<ll, 4> ans = {d[0], d[0], 0, d[1]}; while(v[0] != -1) { array<ll, 2> x = {v[0], par[v[0]][1]}; ans = min(ans, {abs(d[0] - 2 * x[1]), d[0] - x[1], x[1], x[0]}); v = par[v[0]]; } //cout << ans[1] << ' ' << ans[2] << ' ' << ans[3] << '\n'; cost.push_back({d[0], ans[3]}); } sort(cost.rbegin(), cost.rend()); for(ll i = 1; i < cost.size(); i++) { g[cost[0][1]].push_back({cost[i][1], L}); g[cost[i][1]].push_back({cost[0][1], L}); } array<ll, 2> x = dfs(1, -1, 0); ll answer = dfs(x[1], -1, 0)[0]; return answer; }

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

dreaming.cpp: In function 'll travelTime(ll, ll, ll, ll*, ll*, ll*)':
dreaming.cpp:43:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(ll i = 1; i < cost.size(); i++) {
      |                   ~~^~~~~~~~~~~~~
/tmp/ccClxZSI.o: In function `main':
grader.c:(.text.startup+0xc9): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status