# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
70265 | MANcity | Dreaming (IOI13_dreaming) | C++14 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<cstring>
#include<vector>
#include "dreaming.h"
using namespace std;
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define for0(i,n) for(int i=0;i<=(int)n;i++)
#define forn(i,n) for(int i=n;i>=1;i--)
#define fo(i,x,y) for(int i=x;i<=(int)y;i++)
#define fr(i,x,y) for(int i=x;i>=(int)y;i--)
#define pb push_back
#define mp make_pair
#define LL long long
const LL Mod=1000*1000*1000+7;
vector<vector<pair<int,int> > > g(100002);
int max1[100002];
int pos[100002];
int max2[100002];
int verHi[100002];
int used[100002];
int ANSWER;
int DIAM=0;
void dfs_fordown(int v,int p)
{
used[v]=1;
for0(j,g[v].size()-1)
{
int to=g[v][j].first;
int len=g[v][j].second;
if(to!=p)
{
dfs_fordown(to,v);
if((max1[to]+len)>=max1[v])
{
max2[v]=max1[v];
max1[v]=(max1[to]+len);
pos[v]=to;
}
else
{
if((max1[to]+len)>max2[v])
max2[v]=max1[to]+len;
}
}
}
}
int dfs_forup(int v,int p,int lenpar)
{
if(p!=-1)
{
if(pos[p]==v)
verHi[v]=max(verHi[p],max2[p])+lenpar;
else
verHi[v]=max(verHi[p],max1[p])+lenpar;
}
for0(j,g[v].size()-1)
{
int to=g[v][j].first;
int len=g[v][j].second;
if(to!=p)
{
dfs_forup(to,v,len);
}
}
//cout<<v<<" "<<verHi[v]<<" "<<max1[v]<<endl;
ANSWER=min(ANSWER,max(verHi[v],max1[v]));
DIAM=max(DIAM,max(verHi[v],max1[v]));
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
for0(i,M-1)
{
g[A[i]].pb({B[i],T[i]});
g[B[i]].pb({A[i],T[i]});
}
vector<int> D;
int ANS=0;
for0(i,N-1)
{
if(used[i]==0)
{
DIAM=0;
ANSWER=1000000002;
dfs_fordown(i,-1);
dfs_forup(i,-1,0);
ANS=max(ANS,DIAM);
D.push_back(ANSWER);
}
}
int l=D.size();
if(l==1)
return max(ANS,D[0]);
if(l==2)
return max(D[0]+D[1]+L,ANS);
sort(D.begin(),D.end());
ANS=(max([l-1]+D[l-2]+L);
ANS=max(ANS,D[l-2]+D[l-3]+L+L);
return ANS;
}
/*
7 5
1
0 1 30
0 2 2
0 3 30
4 5 4
4 6 5
*/
컴파일 시 표준 에러 (stderr) 메시지
dreaming.cpp: In function 'int dfs_forup(int, int, int)': dreaming.cpp:77:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^ dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)': dreaming.cpp:104:16: error: expected ',' before '-' token ANS=(max([l-1]+D[l-2]+L); ^ dreaming.cpp:104:16: error: expected identifier before '-' token dreaming.cpp: In lambda function: dreaming.cpp:104:19: error: expected '{' before '+' token ANS=(max([l-1]+D[l-2]+L); ^ dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)': dreaming.cpp:104:19: error: no match for 'operator+' (operand types are 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}') ANS=(max([l-1]+D[l-2]+L); In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:397:5: note: candidate: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&) operator+(typename reverse_iterator<_Iterator>::difference_type __n, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:397:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: mismatched types 'const std::reverse_iterator<_Iterator>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1198:5: note: candidate: template<class _Iterator> std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&) operator+(typename move_iterator<_Iterator>::difference_type __n, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1198:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: mismatched types 'const std::move_iterator<_IteratorL>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5876:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5876:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:53:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.tcc:1157:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(const _CharT* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.tcc:1157:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: mismatched types 'const _CharT*' and 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:53:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.tcc:1173:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) ^~~~~~~~ /usr/include/c++/7/bits/basic_string.tcc:1173:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5913:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5913:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5929:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5929:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5941:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5941:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5947:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5947:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5953:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5953:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5965:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(const _CharT* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5965:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: mismatched types 'const _CharT*' and 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5971:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) operator+(_CharT __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5971:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5977:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5977:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from dreaming.cpp:1: /usr/include/c++/7/bits/basic_string.h:5983:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, _CharT) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:5983:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/deque:64:0, from /usr/include/c++/7/queue:60, from dreaming.cpp:7: /usr/include/c++/7/bits/stl_deque.h:374:5: note: candidate: template<class _Tp, class _Ref, class _Ptr> std::_Deque_iterator<_Tp, _Ref, _Ptr> std::operator+(std::ptrdiff_t, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&) operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x) ^~~~~~~~ /usr/include/c++/7/bits/stl_deque.h:374:5: note: template argument deduction/substitution failed: dreaming.cpp:104:25: note: mismatched types 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}' ANS=(max([l-1]+D[l-2]+L); ^ In file included from /usr/include/c++/7/vector:65:0, from /usr/include/c++/7/queue:61, from dreaming.cpp:7: /usr/include/c++/7/bits/stl_bvector.h:297:3: note: candidate: std::_Bit_iterator std::operator+(std::ptrdiff_t, const std::_Bit_iterator&) operator+(ptrdiff_t __n, const _Bit_iterator& __x) ^~~~~~~~ /usr/include/c++/7/bits/stl_bvector.h:297:3: note: no known conversion for argument 1 from 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' to 'std::ptrdiff_t {aka long int}' /usr/include/c++/7/bits/stl_bvector.h:387:3: note: candidate: std::_Bit_const_iterator std::operator+(std::ptrdiff_t, const std::_Bit_const_iterator&) operator+(ptrdiff_t __n, const _Bit_const_iterator& __x) ^~~~~~~~ /usr/include/c++/7/bits/stl_bvector.h:387:3: note: no known conversion for argument 1 from 'travelTime(int, int, int, int*, int*, int*)::<lambda()>' to 'std::ptrdiff_t {aka long int}' dreaming.cpp:104:29: error: expected ')' before ';' token ANS=(max([l-1]+D[l-2]+L); ^