제출 #890469

#제출 시각아이디문제언어결과실행 시간메모리
890469oblantis경주 (Race) (IOI11_race)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "race.h" //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; //using namespace __gnu_pbds; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, int> pdi; const ll inf = 1e9 + 10000; const int mod = 1e9+7; const int maxn = 2e5 + 12; //typedef tree< //int, //null_type, //less<int>, //rb_tree_tag, //tree_order_statistics_node_update> //ordered_set; vector<pii> g[maxn]; int sz[maxn], ans = maxn, k; bool was[maxn]; void dfs(int v, int pr) { sz[v] = 1; for(auto i : g[v]) { if(!was[i.ff] && i.ff != pr) { dfs(i.ff, v); sz[v] += sz[i.ff]; } } } int fnd(int v, int pr, int n) { for(auto i : g[v]) { if(!was[i.ff] && i.ff != pr){ if(sz[i.ff] > n / 2) { return fnd(i.ff, v, n); } } } return v; } map<int, int> ok; vector<pii> upd; void cnt(int v, int pr, int x, int y) { if(x <= k){ if(ok.find(k - x) != ok.end())ans = min(ans, ok[k - x] + y); } else x = k + 1; sz[v] = 1; for(auto i : g[v]) { if(i.ff != pr && !was[i.ff]) { cnt(i.ff, v, min(x + i.ss, k + 1), y + 1); sz[v] += sz[i.ff]; } } upd.pb({x, y}); } void go(int v, int n) { dfs(v, -1); int cen = fnd(v, -1, n); was[cen] = 1; ok.clear(); ok[0] = 0; for(auto i : g[cen]){ if(!was[i.ff]){ cnt(i.ff, cen, i.ss, 1); while(!upd.empty()){ if(ok.find(upd.back().ff) == ok.end())ok[upd.back().ff] = upd.back().ss; else ok[upd.back().ff] = min(ok[upd.back().ff], upd.back().ss); upd.pop_back(); } } } for(auto i : g[cen]){ if(!was[i.ff]){ go(i.ff, sz[i.ff]); } } } int best_path(int n, int K, int h[][2], int l[]){ k = K; for(int i = 0; i < n; i++ ){ g[h[i][0]].pb({h[i][1], l[i]}); g[h[i][1]].pb({h[i][0], l[i]}); } go(0, n); if( return (ans == maxn ? -1 : ans); }

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

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:96:2: error: expected primary-expression before 'return'
   96 |  return (ans == maxn ? -1 : ans);
      |  ^~~~~~
race.cpp:97:1: error: expected primary-expression before '}' token
   97 | }
      | ^
race.cpp:96:34: error: expected ')' before '}' token
   96 |  return (ans == maxn ? -1 : ans);
      |                                  ^
      |                                  )
   97 | }
      | ~                                 
race.cpp:95:4: note: to match this '('
   95 |  if(
      |    ^
race.cpp:97:1: error: expected primary-expression before '}' token
   97 | }
      | ^
race.cpp:97:1: warning: no return statement in function returning non-void [-Wreturn-type]