Submission #1214787

#TimeUsernameProblemLanguageResultExecution timeMemory
1214787spetrToy (CEOI24_toy)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll mmod = 998244353; #define vl vector<long long> #define vll vector<vector<long long>> ll intersect(ll l1, ll r1, ll l2, ll r2){ return max(0, min(r1,r2) - max(l1,l2) + 1); } vector<vector<bool>> visited; ll w,h,k,l; vector<string> graf; vll leva; vll prava; vll up; vll down; void dfs(ll y, ll x){ visited[y][x] = true; vll dirs = {{1,0},{-1,0},{0,1},{0,-1}}; if (graf[y][x] == '*'){ cout << "YES"; exit(0); } for (int i = 0; i < 4; i++){ ll nx, ny; nx = x + dirs[i][0]; ny = y + dirs[i][1]; if (nx >= 0 && ny >= 0 && nx < w && ny < h && graf[ny][nx] != 'X'){ if (visited[ny][nx] == false){ visited[ny][nx] = true; if (intersect(x - prava[y][x], x + leva[y][x], nx - prava[ny][nx], nx + leva[ny][nx]) >= k){ if (intersect(y - down[y][x], y + up[y][x], ny - down[ny][nx], ny + up[ny][nx]) >= l){ dfs(ny, nx); } } } } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> w >> h >> k >> l; ll kx, ky, lx, ly; cin >> kx >> ky >> lx >> ly; //k-horiznot a l-vertikal for (ll i = 0; i < h; i++){ string radek; cin >> radek; graf.push_back(radek); } for (ll i = 0; i < h; i++){ vector<bool> radek; for (ll j = 0; j < w; j++){ radek.push_back(false); } visited.push_back(radek); } // Kontrola, že se vejdou for (ll i = 0; i < h; i++){ vl radek; for (ll j = 0; j < w; j++){ radek.push_back(0); } leva.push_back(radek); prava.push_back(radek); up.push_back(radek); down.push_back(radek); } for (ll i = 0; i < w; i++){ ll aktual1, aktual2; aktual1 = 0; aktual2 = 0; for (ll j = 0; j < h; j++){ if (graf[j][i] != 'X'){ down[j][i] = aktual1; aktual1++; } else{ aktual1 = 0; } } for (ll j = h-1; j >= 0; j--){ if (graf[j][i] != 'X'){ up[j][i] = aktual2; aktual2++; } else{ aktual2 = 0; } } } for (ll i = 0; i < h; i++){ ll aktual1 = 0; ll aktual2 = 0; for (ll j = 0; j < w; j++){ if (graf[i][j] != 'X'){ prava[i][j] = aktual1; aktual1++; } else{ aktual1 = 0; } } for (ll j = w-1; j >= 0; j--){ if (graf[i][j] != 'X'){ leva[i][j] = aktual2; aktual2++; } else{ aktual2 = 0; } } } dfs(ky, lx); cout << "NO"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'long long int intersect(long long int, long long int, long long int, long long int)':
Main.cpp:12:15: error: no matching function for call to 'max(int, long long int)'
   12 |     return max(0, min(r1,r2) - max(l1,l2) + 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:12:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   12 |     return max(0, min(r1,r2) - max(l1,l2) + 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:12:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   12 |     return max(0, min(r1,r2) - max(l1,l2) + 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 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/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
Main.cpp:12:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |     return max(0, min(r1,r2) - max(l1,l2) + 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 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/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
Main.cpp:12:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |     return max(0, min(r1,r2) - max(l1,l2) + 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~