Submission #862665

#TimeUsernameProblemLanguageResultExecution timeMemory
862665hjroh0315Xylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include"xylophone.h" using namespace std; using ll=long long; const ll inf=1e18; void solve(int N) { vector<ll>D1(N),D2(N),dist(N+1,inf); for(int i=1;i<N;i++)D1[i]=query(i,i+1); for(int i=2;i<N;i++)D2[i]=query(i-1,i+1); vector<array<ll,3>>edge; for(int i=1;i<N;i++)edge.push_back(array{i,i+1,D1[i]}); for(int i=2;i<N;i++)if(D2[i]!=D1[i-1]+D1[i])edge.push_back(array{i-1,i+1,abs(D1[i]-D1[i-1])}); dist[1]=0; for(int t=0;t<N;t++) for(auto[u,v,w]:edge) { dist[v]=min(dist[v],dist[u]+w); dist[u]=min(dist[u],dist[v]+w); } ll mn=inf; for(int i=1;i<=N;i++)mn=min(mn,dist[i]); for(int i=1;i<=N;i++)dist[i]+=mn+1; mn=inf; ll mi=-1,mx=-inf,mxi=-1; for(int i=1;i<=N;i++) { if(mn>dist[i]){mn=dist[i];mi=i;} if(mx<dist[i]){mx=dist[i];mxi=i;} } if(mi>mxi)reverse(begin(dist)+1,end(dist)); for(int i=1;i<=N;i++)answer(i,dist[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:13:57: error: class template argument deduction failed:
   13 |     for(int i=1;i<N;i++)edge.push_back(array{i,i+1,D1[i]});
      |                                                         ^
xylophone.cpp:13:57: error: no matching function for call to 'array(int&, int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/array:94:12: note: candidate: 'template<class _Tp, long unsigned int _Nm> array()-> std::array<_Tp, _Nm>'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   template argument deduction/substitution failed:
xylophone.cpp:13:57: note:   candidate expects 0 arguments, 3 provided
   13 |     for(int i=1;i<N;i++)edge.push_back(array{i,i+1,D1[i]});
      |                                                         ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/array:94:12: note: candidate: 'template<class _Tp, long unsigned int _Nm> array(std::array<_Tp, _Nm>)-> std::array<_Tp, _Nm>'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   template argument deduction/substitution failed:
xylophone.cpp:13:57: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   13 |     for(int i=1;i<N;i++)edge.push_back(array{i,i+1,D1[i]});
      |                                                         ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/array:244:5: note: candidate: 'template<class _Tp, class ... _Up> std::array(_Tp, _Up ...)-> std::array<typename std::enable_if<(is_same_v<_Tp, _Up> && ...), _Tp>::type, (1 + sizeof... (_Up))>'
  244 |     array(_Tp, _Up...)
      |     ^~~~~
/usr/include/c++/10/array:244:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/array: In substitution of 'template<class _Tp, class ... _Up> std::array(_Tp, _Up ...)-> std::array<typename std::enable_if<(is_same_v<_Tp, _Up> && ...), _Tp>::type, (1 + sizeof... (_Up))> [with _Tp = int; _Up = {int, long long int}]':
xylophone.cpp:13:57:   required from here
/usr/include/c++/10/array:244:5: error: no type named 'type' in 'struct std::enable_if<false, int>'
xylophone.cpp:14:96: error: class template argument deduction failed:
   14 |     for(int i=2;i<N;i++)if(D2[i]!=D1[i-1]+D1[i])edge.push_back(array{i-1,i+1,abs(D1[i]-D1[i-1])});
      |                                                                                                ^
xylophone.cpp:14:96: error: no matching function for call to 'array(int, int, long long int)'
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/array:94:12: note: candidate: 'template<class _Tp, long unsigned int _Nm> array()-> std::array<_Tp, _Nm>'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   template argument deduction/substitution failed:
xylophone.cpp:14:96: note:   candidate expects 0 arguments, 3 provided
   14 |     for(int i=2;i<N;i++)if(D2[i]!=D1[i-1]+D1[i])edge.push_back(array{i-1,i+1,abs(D1[i]-D1[i-1])});
      |                                                                                                ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/array:94:12: note: candidate: 'template<class _Tp, long unsigned int _Nm> array(std::array<_Tp, _Nm>)-> std::array<_Tp, _Nm>'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   template argument deduction/substitution failed:
xylophone.cpp:14:96: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   14 |     for(int i=2;i<N;i++)if(D2[i]!=D1[i-1]+D1[i])edge.push_back(array{i-1,i+1,abs(D1[i]-D1[i-1])});
      |                                                                                                ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/array:244:5: note: candidate: 'template<class _Tp, class ... _Up> std::array(_Tp, _Up ...)-> std::array<typename std::enable_if<(is_same_v<_Tp, _Up> && ...), _Tp>::type, (1 + sizeof... (_Up))>'
  244 |     array(_Tp, _Up...)
      |     ^~~~~
/usr/include/c++/10/array:244:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/array: In substitution of 'template<class _Tp, class ... _Up> std::array(_Tp, _Up ...)-> std::array<typename std::enable_if<(is_same_v<_Tp, _Up> && ...), _Tp>::type, (1 + sizeof... (_Up))> [with _Tp = int; _Up = {int, long long int}]':
xylophone.cpp:14:96:   required from here
/usr/include/c++/10/array:244:5: error: no type named 'type' in 'struct std::enable_if<false, int>'