Submission #674192

#TimeUsernameProblemLanguageResultExecution timeMemory
674192Megumin2006Race (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ull unsigned long long #define ed '\n' #define pb push_back #define int long long #define ii pair<int,int> #define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define fi first #define se second using namespace __gnu_pbds; using namespace std; const int N = 2e5 + 10; ii lazy[N]; vector<ii> g[N]; int n, k, ans = 1e18; map<int, int> f[N]; void Merge(int u, int v) { if (f[u].size() < f[v].size()) { swap(lazy[u], lazy[v]); f[u].swap(f[v]); } for(pair<int, int> tmp: f[v]) { int num = tmp.fi + lazy[v].fi; int Min = tmp.se + lazy[v].se; auto t = f[u].find(k - num - lazy[u].fi); if (t != f[u].end()) { if (t->se + Min + lazy[u].se < ans) { ans = t->se + Min + lazy[u].se; } } // if (f[u].find(num - lazy[u].fi) == f[u].end()) { // f[u][num - lazy[u].fi] = Min - lazy[u].se; // } if (f[u][num - lazy[u].fi] == 0) f[u][num - lazy[u].fi] = Min - lazy[u].se; else { if (Min - lazy[u].se < f[u][num - lazy[u].fi]) { f[u][num - lazy[u].fi] = Min - lazy[u].se; } } } } void dfs(int u, int p, int val) { f[u][0] = 0; for(ii &e: g[u]) if (e.fi != p) { dfs(e.fi, u, e.se); Merge(u, e.fi); } lazy[u].fi += val; lazy[u].se ++; } int best_path(int N, int K, int H[][2], int L[]) { n = N, k = K; for(int i=0;i<n-1;i++) { g[H[i][0]+1].pb({H[i][1]+1,L[i]}); g[H[i][1]+1].pb({H[i][0]+1,L[i]}); } cin >> n >> k; for(int i = 1; i < n; ++i) { int u, v, l; cin >> u >> v >> l; g[u].pb({v, l}); g[v].pb({u, l}); } dfs(0, -1, 0); if (ans == 1e18) ans = -1; cout << ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen("cf.inp", "r")) { freopen("cf.inp", "r", stdin); // freopen("1.out", "w", stdout); } //solve(); return 0; }

Compilation message (stderr)

race.cpp: In function 'long long int best_path(long long int, long long int, long long int (*)[2], long long int*)':
race.cpp:83:1: warning: no return statement in function returning non-void [-Wreturn-type]
   83 | }
      | ^
race.cpp: In function 'int main()':
race.cpp:88:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |         freopen("cf.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccNbpA5y.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUn88uB.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccUn88uB.o: in function `main':
grader.cpp:(.text.startup+0x28): undefined reference to `best_path(int, int, int (*) [2], int*)'
collect2: error: ld returned 1 exit status