Submission #1068942

#TimeUsernameProblemLanguageResultExecution timeMemory
1068942farukText editor (CEOI24_editor)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define all(a) a.begin(), a.end() #define mp make_pair using namespace std; typedef long long ll; typedef pair<int, int> pii; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; pii f, t; cin >> f.first >> f.second; f.second--; f.first--; cin >> t.first >> t.second; t.first--; t.second--; vector<ll> len(n); for (int i = 0; i < n; i++) { cin >> len[i]; } if (*max_element(all(len) - 1) != *min_element(all(len) - 1)) { vector<vector<int> > dist(n); for (int i = 0; i < n; i++) dist[i].resize(len[i] + 1, 1e9); dist[f.first][f.second] = 0; queue<pii> q; q.push(f); while (!q.empty()) { pii curr = q.front(); q.pop(); vector<pii> nei; pii lft = curr; if (lft.second > 0) lft.second--; else if (lft.first != 0) lft = pii(lft.first - 1, len[lft.first - 1]); pii rght = curr; if (rght.second < len[rght.first]) rght.second++; else if (rght.first < n - 1) rght.second = 0, rght.first++; pii up = curr; if (curr.first != 0) { up.first--; up.second = min(up.second, len[up.first]); } pii down = curr; if (curr.first != n - 1) { down.first++; down.second = min(down.second, len[down.first]); } nei = {up, down, rght, lft}; for (pii guy : nei) { if (dist[guy.first][guy.second] != 1e9) continue; dist[guy.first][guy.second] = dist[curr.first][curr.second] + 1; q.push(guy); } } cout << dist[t.first][t.second] << "\n"; } ll f_idx = f.first * len[0] + f.second; ll t_idx = t.first * len[0] + t.second; if (t.first == n - 1) { cout << t.first - f.first << "\n"; return 0; } int cnt = 0; while (abs(f_idx - t_idx) >= len[0]) { if (f_idx > t_idx) f_idx += len[0]; else f_idx -= len[0]; cnt++; } cnt += min(abs(f_idx - t_idx), abs(f_idx - t_idx + len[0]), abs(f_idx - t_idx - len[0])); cout <<cnt << "\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:58:57: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   58 |                 up.second = min(up.second, len[up.first]);
      |                                                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:58:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   58 |                 up.second = min(up.second, len[up.first]);
      |                                                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:58:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   58 |                 up.second = min(up.second, len[up.first]);
      |                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:58:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |                 up.second = min(up.second, len[up.first]);
      |                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:58:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |                 up.second = min(up.second, len[up.first]);
      |                                                         ^
Main.cpp:64:63: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   64 |                 down.second = min(down.second, len[down.first]);
      |                                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:64:63: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   64 |                 down.second = min(down.second, len[down.first]);
      |                                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:64:63: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   64 |                 down.second = min(down.second, len[down.first]);
      |                                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:64:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   64 |                 down.second = min(down.second, len[down.first]);
      |                                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:64:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   64 |                 down.second = min(down.second, len[down.first]);
      |                                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
Main.cpp:95:92:   required from here
/usr/include/c++/10/bits/stl_algobase.h:281:17: error: '__comp' cannot be used as a function
  281 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~