Submission #1129035

#TimeUsernameProblemLanguageResultExecution timeMemory
1129035pcheloveksToll (BOI17_toll)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("avx,avx2,tune=native") #include <iostream> #include <vector> #include <map> #include <set> #include <fstream> #include <algorithm> #include <cstring> // Для memset #define endl '\n' using namespace std; typedef long long LL; typedef pair<LL, LL> pii; const LL DIM = 50007; const LL INF = 999999999999; LL n, k, o, m; class edge { public: LL to, w; }; vector < edge > v[DIM]; class tran { public: LL mat[5][5]; void init() { for (int i = 0; i < k; i++) { for (int j = 0; j < k; j++) { mat[i][j] = INF; } } } }; tran solve(LL L, LL R) { tran ans; ans.init(); if (R - L == 1) { for (int i = 0; i < k; i++) { LL val = L * k + i; for (auto to : v[val]) { ans.mat[i][to.to - (R * k)] = to.w; } } return ans; } LL mid = (L + R) / 2; tran m1 = solve(L, mid); tran m2 = solve(mid, R); for (int l = 0; l < k; l++) { for (int r = 0; r < k; r++) { for (int m = 0; m < k; m++) { ans.mat[l][r] = min(ans.mat[l][r], m1.mat[l][m] + m2.mat[m][r]); } } } return ans; } LL a, b, res, b1, b2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); LL k, n, m, o; scanf("%lld %lld %lld %lld", &k, &n, &m, &o); for (int i = 1; i <= m; i++) { LL a, b, t; scanf("%lld %lld %lld", &a, &b, &t); v[a].emplace_back(b, t); } vector<LL> out; for (int i = 1; i <= o; i++) { LL a, b; scanf("%lld %lld", &a, &b); LL b1 = a / k; LL b2 = b / k; if (b1 >= b2 || m == 0) { out.push_back(-1); } else { tran res = solve(b1, b2); LL result = res.mat[a - b1 * k][b - b2 * k]; if (result >= INF) out.push_back(-1); else out.push_back(result); } } for (auto x : out) { printf("%lld\n", x); } return 0; }

Compilation message (stderr)

In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/c++allocator.h:33,
                 from /usr/include/c++/11/bits/allocator.h:46,
                 from /usr/include/c++/11/string:41,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from toll.cpp:5:
/usr/include/c++/11/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = edge; _Args = {long long int&, long long int&}; _Tp = edge]':
/usr/include/c++/11/bits/alloc_traits.h:516:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = edge; _Args = {long long int&, long long int&}; _Tp = edge; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<edge>]'
/usr/include/c++/11/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&}; _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::reference = edge&]'
toll.cpp:85:26:   required from here
/usr/include/c++/11/ext/new_allocator.h:162:11: error: new initializer expression list treated as compound expression [-fpermissive]
  162 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/ext/new_allocator.h:162:11: error: no matching function for call to 'edge::edge(long long int&)'
toll.cpp:24:7: note: candidate: 'edge::edge()'
   24 | class edge {
      |       ^~~~
toll.cpp:24:7: note:   candidate expects 0 arguments, 1 provided
toll.cpp:24:7: note: candidate: 'constexpr edge::edge(const edge&)'
toll.cpp:24:7: note:   no known conversion for argument 1 from 'long long int' to 'const edge&'
toll.cpp:24:7: note: candidate: 'constexpr edge::edge(edge&&)'
toll.cpp:24:7: note:   no known conversion for argument 1 from 'long long int' to 'edge&&'
toll.cpp: In function 'int main()':
toll.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |     scanf("%lld %lld %lld %lld", &k, &n, &m, &o);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toll.cpp:84:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         scanf("%lld %lld %lld", &a, &b, &t);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toll.cpp:92:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |         scanf("%lld %lld", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~