Submission #1135939

#TimeUsernameProblemLanguageResultExecution timeMemory
1135939dadas08Dreaming (IOI13_dreaming)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // #define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> // #define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); return 0; } using ll = long long; using ull = unsigned long long; using ld = long double; using vi = std::vector<int>; using vvi = std::vector<vi>; using vl = std::vector<ll>; using vii = std::vector<pair<int, int> >; using vvl = std::vector<vl>; using vll = std::vector<pair<ll , ll> >; using vd = std::vector<double>; using vvd = std::vector<vd>; using vs = std::vector<std::string>; using vvs = std::vector<vs>; using vb = std::vector<bool>; using vvb = std::vector<vb>; using vc = std::vector<char>; using vvc = std::vector<vc>; using pii = std::pair<int, int>; using pll = std::pair<ll, ll>; using piil = std::pair<pair<int, int>, ll>; using mii = std::map<int, int>; using mll = std::map<ll, ll>; using pql = std::priority_queue<ll>; using pqi = std::priority_queue<int>; using pqiil = std::priority_queue<pair<pair<int, int>, ll> >; using pqii = std::priority_queue<pair<int, int> >; #define pb push_back #define ps push #define eb emplace_back #define is insert #define er erase #define f first #define s second #define lb lower_bound #define ub upper_bound #define sf(i) sizeof(i) #define endl "\n" #define all(v) (v).begin(), (v).end() #define rep(i, L, R) for(ll i = L;i<=R;i++) #define pcis precision #define sz(a) ((ll) a.size()) template<typename T> struct infinity { static constexpr T max=std::numeric_limits<T>::max(); static constexpr T min=std::numeric_limits<T>::min(); static constexpr T value=std::numeric_limits<T>::max()/2; static constexpr T mvalue=std::numeric_limits<T>::min()/2; }; template<typename T>constexpr T INF=infinity<T>::value; constexpr ll lINF=INF<ll>; constexpr int iINF = INF<int>; constexpr ld PI = 3.1415926535897932384626; ll N, M, L; bool vst[100001]; vll adj[100001]; ll down[100001]; ll sz[100001]; void DFS1(ll node, ll par) { sz[node] = 1; for (auto [i, w] : adj[node]) { if (i==par) continue; DFS1(i, node); sz[node] += sz[i]; down[node] = max(down[node], w + down[i]); } return; } ll DFS2(ll node, ll par, ll up) { ll MN = max(up, down[node]); vst[node] = true; ll mx1 = up; ll mxat = -1; ll mx2 = 0; for (auto [i, w] : adj[node]) { if (i==par) continue; if (down[i]+w >= mx1) { mx2 = mx1; mxat = i; mx1 = down[i] + w; } else if (down[i] + w >= mx2) { mx2 = down[i] + w; } } for (auto [i, w] : adj[node]) { if (i==par) continue; if (mxat == i) { MN = min(MN, DFS2(i, node, mx2 + w)); } else { MN = min(MN, DFS2(i, node, mx1 + w)); } } return MN; } void _main() { cin >>N >>M >>L; for (ll i = 1; i<=M; i++) { ll a, b, c; cin >>a >> b >> c; adj[a].pb({b, c}); adj[b].pb({a, c}); } vl lst; for (ll i = 1; i<=N; i++) { if (!vst[i]) { DFS1(i, -1); lst.pb(DFS2(i, -1, 0)); } } sort(all(lst)); reverse(all(lst)); if (lst.size() == 1) { cout << lst[0] << endl; } else if (lst.size() == 2) { cout << lst[0] + lst[1] + L << endl; } else { cout << max(lst[0] + lst[1] + L, lst[1] + lst[2] + 2*L) << endl; } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccSjCPWQ.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/ccFcrdi9.o:dreaming.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccSjCPWQ.o: in function `main':
grader.c:(.text.startup+0xc4): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status