Submission #1370280

#TimeUsernameProblemLanguageResultExecution timeMemory
1370280eyadoozZoo (COCI19_zoo)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'
#define int long long

int ne[4]={0, 0, 1, -1}, nex[4]={1, -1, 0, 0};
main()
{
    cin.tie(0) -> sync_with_stdio(0);

    int n, m;
    cin >> n >> m;
    string a[n];
    for(auto& i : a) cin >> i;
    int dis[n+1][m+1]={};
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) dis[i][j]=LONG_LONG_MAX;
    priority_queue<array<int, 3>> q;
    dis[0][0]=0;
    q.push({0, 0});
    int mx=0;
    while(sz(q)) {
        auto[cw, curx, cury]=q.front();
        cw*=-1;
        q.pop();
        if(cw!=dis[curx][cury]) continue;
        for(int i = 0;i < 4;i++) {
            int nx=curx+ne[i], ny=cury+nex[i];
            if(nx>=n||nx<0||ny>=m||ny<0||a[nx][ny]=='*') continue;
            if(dis[nx][ny]>cw+(a[curx][cury]!=a[nx][ny]))
            {
                dis[nx][ny]=cw+(a[curx][cury]!=a[nx][ny]);
                mx=max(mx, dis[nx][ny]);
                q.push({-dis[nx][ny], nx, ny});
            }
        }
    }
    cout << mx << endl;
}

Compilation message (stderr)

zoo.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      | ^~~~
zoo.cpp: In function 'int main()':
zoo.cpp:30:32: error: 'class std::priority_queue<std::array<long long int, 3> >' has no member named 'front'
   30 |         auto[cw, curx, cury]=q.front();
      |                                ^~~~~
zoo.cpp:36:29: error: 'ny' was not declared in this scope; did you mean 'nx'?
   36 |             if(nx>=n||nx<0||ny>=m||ny<0||a[nx][ny]=='*') continue;
      |                             ^~
      |                             nx
zoo.cpp:37:24: error: 'ny' was not declared in this scope; did you mean 'nx'?
   37 |             if(dis[nx][ny]>cw+(a[curx][cury]!=a[nx][ny]))
      |                        ^~
      |                        nx
zoo.cpp:41:23: error: no matching function for call to 'std::priority_queue<std::array<long long int, 3> >::push(<brace-enclosed initializer list>)'
   41 |                 q.push({-dis[nx][ny], nx, ny});
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
                 from zoo.cpp:1:
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::array<long long int, 3>; _Sequence = std::vector<std::array<long long int, 3>, std::allocator<std::array<long long int, 3> > >; _Compare = std::less<std::array<long long int, 3> >; value_type = std::array<long long int, 3>]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::array<long long int, 3> >::value_type&' {aka 'const std::array<long long int, 3>&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::array<long long int, 3>; _Sequence = std::vector<std::array<long long int, 3>, std::allocator<std::array<long long int, 3> > >; _Compare = std::less<std::array<long long int, 3> >; value_type = std::array<long long int, 3>]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::array<long long int, 3> >::value_type&&' {aka 'std::array<long long int, 3>&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~