Submission #482219

#TimeUsernameProblemLanguageResultExecution timeMemory
482219M_W꿈 (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "dreaming.h" #define ii pair<int, int> using namespace std; vector<ii> adj[100001]; int pa[100001], from[100001], dist[100001]; bitset<100001> mark, mark2; int findpa(int a){ return (pa[a] == a ? a : pa[a] = findpa(pa[a])); } ii longestDist(int st){ queue<ii> q; ii best = make_pair(-1, 0); q.push(make_pair(0, st)); mark[st] = 1; while(!q.empty()){ int d = q.front().first; int n = q.front().second; q.pop(); if(d > best.first){ best = make_pair(d, n); } for(auto x : adj[n]){ if(!mark[x.first]){ mark[x.first] = 1; q.push(make_pair(d + x.second, x.first)); } } } q.push(make_pair(0, best.second)); mark2[best.second] = 1; best = make_pair(-1, 0); while(!q.empty()){ int d = q.front().first; int n = q.front().second; q.pop(); dist[n] = d; if(d > best.first){ best = make_pair(d, n); } for(auto x : adj[n]){ if(!mark2[x.first]){ from[x.first] = n; mark2[x.first] = 1; q.push(make_pair(d + x.second, x.first)); } } } int mid = INT_MAX; for(int i = best.second; i != 0; i = from[i]){ mid = min(mid, max(best.first - dist[i], dist[i])); } return make_pair(best.first, mid); } int travelTime(int N, int M, int L, int A[], int B[], int T[]){ for(int i = 1; i <= N; i++) pa[i] = i; for(int i = 0; i < M; i++){ A[i]++; B[i]++; adj[A[i]].emplace_back(B[i], T[i]); adj[B[i]].emplace_back(A[i], T[i]); if(findpa(A[i]) != findpa(B[i])){ pa[findpa(B[i])] = findpa(A[i]); } } priority_queue<ii> pq; for(int i = 1; i <= N; i++){ if(pa[i] == i){ ii tmp = longestDist(i); pq.push(tmp); } } if(pq.size() == 1) return 0; int cnt = 2, ans = 0; int aaa = pq.top().first; while(cnt--){ ans += pq.top().second; pq.pop(); } return max(aaa, ans + L, 2 * L); } /* int main(){ int N, M, L; scanf("%d %d %d", &N, &M, &L); int a[M], b[M], c[M]; for(int i = 0; i < M; i++){ scanf("%d %d %d", &a[i], &b[i], &c[i]); } printf("%d", travelTime(N, M, L, a, b, c)); } */

Compilation message (stderr)

In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
dreaming.cpp:87:32:   required from here
/usr/include/c++/10/bits/stl_algobase.h:303:17: error: '__comp' cannot be used as a function
  303 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~