# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29668 | aybala | Dreaming (IOI13_dreaming) | C++11 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dreaming.h"
#include<bits/stdc++.h>
#define fori(a,b,c) for(int a=b; a<c; a++)
#define ford(a,b,c) for(int a=b; a>=c; a++)
#define pb push_back
#define pq priority_queue
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define ll long long
using namespace std;
vector< pii >v[100004];
ll dis[100004];
ll disr[100004];
vector< int >el[2];
bool vis[100004];
ll ans[2][2];
void dfs(int u, int pre, int gr){
int s=v[u].size();
vis[u]=1;
el[gr].pb(u);
fori(i,0,s){
if(pre!=v[u][i].fi){
dis[v[u][i].fi]+=dis[u]+v[u][i].se;
dfs(v[u][i].fi,u,gr);
}
}
}
int n;
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
n=N;
fori(i,0,M){
v[A[i]].pb(mp(B[i],T[i]));
v[B[i]].pb(mp(A[i],T[i]));
}
int gr=0;
fori(i,0,n){
if(v[i].size()==1 && !vis[i]){
dfs(i,i,gr);
int s=el[gr].size();
int uu=el[gr][s-1];
fori(j,0,s){
disr[el[gr][j]]=dis[uu]-dis[el[gr][j]];
if(j==0){
ans[gr][0]=el[gr][j];
ans[gr][1]=max(disr[el[gr][j]],dis[el[gr][j]]);
}
else if(ans[gr][1]>max(disr[el[gr][j]],dis[el[gr][j]])){
ans[gr][1]=max(disr[el[gr][j]],dis[el[gr][j]]);
ans[gr][0]=el[gr][j];
}
}
gr++;
}
}
ll res=0;
fori(i,0,2){
int u = el[i][0];
res=max(ans,disr[u]);
res=max(ans,dis[ans[i][0]]+L+ans[(i+1)%2][1]);
u = el[i][el[i].size()-1];
res=max(ans,dis[u]);
res=max(ans,disr[ans[i][0]]+L+ans[(i+1)%2][1]);
}
return res;
}
Compilation message (stderr)
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)': dreaming.cpp:63:22: error: no matching function for call to 'max(long long int [2][2], long long int&)' res=max(ans,disr[u]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: dreaming.cpp:63:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,disr[u]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: dreaming.cpp:63:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,disr[u]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: dreaming.cpp:63:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,disr[u]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: dreaming.cpp:63:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,disr[u]); ^ dreaming.cpp:64:47: error: no matching function for call to 'max(long long int [2][2], long long int)' res=max(ans,dis[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: dreaming.cpp:64:47: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,dis[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: dreaming.cpp:64:47: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,dis[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: dreaming.cpp:64:47: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,dis[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: dreaming.cpp:64:47: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,dis[ans[i][0]]+L+ans[(i+1)%2][1]); ^ dreaming.cpp:67:21: error: no matching function for call to 'max(long long int [2][2], long long int&)' res=max(ans,dis[u]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: dreaming.cpp:67:21: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,dis[u]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: dreaming.cpp:67:21: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,dis[u]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: dreaming.cpp:67:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,dis[u]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: dreaming.cpp:67:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,dis[u]); ^ dreaming.cpp:68:48: error: no matching function for call to 'max(long long int [2][2], long long int)' res=max(ans,disr[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&) max(const _Tp& __a, const _Tp& __b) ^~~ /usr/include/c++/7/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed: dreaming.cpp:68:48: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,disr[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/bits/char_traits.h:39:0, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare) max(const _Tp& __a, const _Tp& __b, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed: dreaming.cpp:68:48: note: deduced conflicting types for parameter 'const _Tp' ('long long int [2][2]' and 'long long int') res=max(ans,disr[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^~~ /usr/include/c++/7/bits/stl_algo.h:3462:5: note: template argument deduction/substitution failed: dreaming.cpp:68:48: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,disr[ans[i][0]]+L+ans[(i+1)%2][1]); ^ In file included from /usr/include/c++/7/algorithm:62:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65, from dreaming.cpp:2: /usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^~~ /usr/include/c++/7/bits/stl_algo.h:3468:5: note: template argument deduction/substitution failed: dreaming.cpp:68:48: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int (*)[2]' res=max(ans,disr[ans[i][0]]+L+ans[(i+1)%2][1]); ^