Submission #933209

#TimeUsernameProblemLanguageResultExecution timeMemory
933209theflessRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define Times (1.0 * clock() / CLOCKS_PER_SEC) #define fi first #define base 31 #define sz(x) (int)(x).size() #define se second #define ll long long #define mp make_pair #define pb push_back #define pii pair<ll, int> #define all(x) (x).begin(), (x).end() #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); } #define task "name" #define tsk "" const int oo = 1e9 + 7; const ll loo = (ll)1e18 + 7; const int MOD = 1e9 + 7; const int MOD2 = 1e9 + 696969; const int N = 2e5 + 3; const int BASE = 10; template <typename T1, typename T2> bool minimize(T1 &a, T2 b){if (a > b) {a = b; return true;} return false;} template <typename T1, typename T2> bool maximize(T1 &a, T2 b){if (a < b) {a = b; return true;} return false;} int n , k; int high[N]; ll d[N]; int ans = oo; vector<pii> adj[N]; map<ll , int> mpp[N]; void make(int u , int par){ mpp[u][d[u]] = high[u]; for(auto x : adj[u]){ int v = x.se; int w = x.fi; if(v == par) continue; d[v] = d[u] + w; high[v] = high[u] + 1; make(v , u); } } void dfs(int u , int par = -1){ int g = k + 2 * d[u]; for(auto x : adj[u]){ int v = x.se; if(v == par) continue; dfs(v , u); if(sz(mpp[u]) < sz(mpp[v])) mpp[u].swap(mpp[v]); for(auto e : mpp[v]){ if(mpp[u].find(g - e.fi) != mpp[u].end()) minimize(ans , mpp[u][g - e.fi] + e.se - 2 * high[u]); } for(auto e : mpp[v]){ if(mpp[u].find(e.fi) == mpp[u].end()) mpp[u].insert(e); else minimize(mpp[u][e.fi] , e.se); } } } void Solve(){ cin >> n >> k; for(int i = 1 ; i < n ; i++){ int u , v , w; cin >> u >> v >> w; adj[u].pb({w , v}); adj[v].pb({w , u}); } make(0 , -1); dfs(0 , -1); cout << (ans == oo ? -1 : ans); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); file(task); file(tsk); int T = 1; // cin >> T; while(T--) { Solve(); } cerr << "Time elapsed: " << Times << " s.\n"; return 0; } // author: thefless // I love Kim Anh

Compilation message (stderr)

race.cpp: In function 'int main()':
race.cpp:16:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:80:5: note: in expansion of macro 'file'
   80 |     file(task);
      |     ^~~~
race.cpp:16:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:80:5: note: in expansion of macro 'file'
   80 |     file(task);
      |     ^~~~
race.cpp:16:125: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:80:5: note: in expansion of macro 'file'
   80 |     file(task);
      |     ^~~~
race.cpp:16:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:81:5: note: in expansion of macro 'file'
   81 |     file(tsk);
      |     ^~~~
race.cpp:16:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:81:5: note: in expansion of macro 'file'
   81 |     file(tsk);
      |     ^~~~
race.cpp:16:125: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:81:5: note: in expansion of macro 'file'
   81 |     file(tsk);
      |     ^~~~
/usr/bin/ld: /tmp/ccgvWCpA.o: in function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccedTFxA.o:grader.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccedTFxA.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