Submission #456125

#TimeUsernameProblemLanguageResultExecution timeMemory
456125PPAP_1264589Dreaming (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define f first #define s second #define up(i, a, b) for (int i = (a); i <= (b); i++) #define pb push_back #define int long long using namespace std; const int oo = 2*100000000000000000; const int maxn = 100001; int n, m, L; vector<pii> a[maxn]; void in(){ cin >> n >> m >> L; int u,v,w; up(i, 1, m){ cin >> u >> v >> w; u++; v++; a[u].pb({v, w}); a[v].pb({u, w}); } } int cost[maxn]; bool dd[maxn]; int dx[maxn]; int dy[maxn]; vector<int> luu; int maxx; void DFS(int u, int parent, int d[]){ dd[u] = 1; luu.emplace_back(u); for (pii x : a[u]){ int v = x.f; int w = x.s; if (v == parent) continue; d[v] = d[u] + w; DFS(v, u, d); } } vector<int> R; int minn = oo; void find_center(int root){ DFS(root, -1, cost); int X = max_element(cost+1, cost+n+1) - cost; DFS(X, -1, dx); int Y = max_element(dx+1, dx+n+1) - dx; DFS(Y, -1, dy); minn = oo; for (auto x : luu){ minn = min(minn, max(dx[x], dy[x])); } R.push_back(minn); for (auto x : luu){ cost[x] = dx[x] = dy[x] = 0; } luu.clear(); } signed main(){ if (fopen("A.inp", "r")){ freopen ("A.inp", "r", stdin); freopen ("A.out", "w", stdout); } in(); up(root, 1, n){ if (!dd[root]){ find_center(root); } } int tplt = R.size(); if (tplt == 1){ cout << minn; } sort(R.begin(), R.end(), greater<int>()); int maxx = -oo; if (tplt > 1){ maxx = max(maxx, R[0] + R[1] + L); } if (tplt > 2){ maxx = max(maxx, R[1] + R[2] + 2*L); } cout << maxx; }

Compilation message (stderr)

dreaming.cpp: In function 'int main()':
dreaming.cpp:71:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen ("A.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
dreaming.cpp:72:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen ("A.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccXOdE01.o: in function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoYoLb1.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccoYoLb1.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status