Submission #1201104

#TimeUsernameProblemLanguageResultExecution timeMemory
1201104pppppMecho (IOI09_mecho)C++20
Compilation error
0 ms0 KiB
// #include "myheader.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>

using namespace std;
#define int long long
// #define ll long long
#define pi pair<int, int>
#define ti tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

vector<vector<char>> grid;
vector<vector<ll>> t;

vector<pi> direction={{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int n;
int s;
int si=-1, sj=-1, ei=-1, ej=-1;

bool bfs(int mid) {
    vector<vector<int>> step(n, vector<int>(n, -1));
    queue<pi> nq;
    
    step[si][sj]=s*mid;
    nq.push({si, sj});
    
    while(nq.size()) {
        auto [i, j]=nq.front(); nq.pop();

        if(grid[i][j]=='D') return true;
        
        for(auto &[di, dj]: direction) {
            int ni=i+di;
            int nj=j+dj;
            
            if(ni>=0 && nj>=0 && ni<n && nj<n && (step[i][j]+1)<s*t[ni][nj] && grid[ni][nj]!='T' && step[ni][nj]==-1) {
                step[ni][nj]=step[i][j]+1;
                nq.push({ni, nj});
            }
        }
    }
    
    return false;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> s;
    
    grid.resize(n, vector<char>(n));
    t.resize(n, vector<int>(n, LLONG_MAX));
    queue<pi> q;
    
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            cin >> grid[i][j];
            
            if(grid[i][j]=='H') {
                q.push({i, j});
                t[i][j]=0;
            } else if(grid[i][j]=='M') {
                si=i;
                sj=j;
            } else if(grid[i][j]=='D') {
                ei=i;
                ej=j;
            }
        }
    }

    while(q.size()) {
        auto [i, j]=q.front(); q.pop();
        
        for(auto &[di, dj]: direction) {
            int ni=i+di;
            int nj=j+dj;
            
            
            if(ni>=0 && nj>=0 && ni<n && nj<n && t[ni][nj]==LLONG_MAX && (grid[ni][nj]!='T' && grid[ni][nj]!='D')) {
                if(t[i][j] == LLONG_MAX) t[ni][nj] = 1;
                else t[ni][nj]=t[i][j]+1;
                q.push({ni, nj});
            }
        }
    }
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < n ; j++) if (t[i][j] == 0) t[i][j] = LLONG_MAX;
    }
    
    int l=-1, r=INT_MAX;
    
    while(l<r) {
        int mid=(l+r+1)/2;
        
        if(bfs(mid)) {
            l=mid;
        } else {
            r=mid-1;
        }
    }
    
    cout << l;
    
    return 0;
}

Compilation message (stderr)

mecho.cpp:15:15: error: 'll' was not declared in this scope; did you mean 'all'?
   15 | vector<vector<ll>> t;
      |               ^~
      |               all
mecho.cpp:15:15: error: template argument 1 is invalid
mecho.cpp:15:15: error: template argument 2 is invalid
mecho.cpp:15:17: error: template argument 1 is invalid
   15 | vector<vector<ll>> t;
      |                 ^~
mecho.cpp:15:17: error: template argument 2 is invalid
mecho.cpp: In function 'bool bfs(long long int)':
mecho.cpp:39:68: error: invalid types 'int[long long int]' for array subscript
   39 |             if(ni>=0 && nj>=0 && ni<n && nj<n && (step[i][j]+1)<s*t[ni][nj] && grid[ni][nj]!='T' && step[ni][nj]==-1) {
      |                                                                    ^
At global scope:
cc1plus: error: '::main' must return 'int'
mecho.cpp: In function 'int main()':
mecho.cpp:57:7: error: request for member 'resize' in 't', which is of non-class type 'int'
   57 |     t.resize(n, vector<int>(n, LLONG_MAX));
      |       ^~~~~~
mecho.cpp:66:18: error: invalid types 'int[long long int]' for array subscript
   66 |                 t[i][j]=0;
      |                  ^
mecho.cpp:85:51: error: invalid types 'int[long long int]' for array subscript
   85 |             if(ni>=0 && nj>=0 && ni<n && nj<n && t[ni][nj]==LLONG_MAX && (grid[ni][nj]!='T' && grid[ni][nj]!='D')) {
      |                                                   ^
mecho.cpp:86:21: error: invalid types 'int[std::tuple_element<0, std::pair<long long int, long long int> >::type {aka long long int}]' for array subscript
   86 |                 if(t[i][j] == LLONG_MAX) t[ni][nj] = 1;
      |                     ^
mecho.cpp:86:43: error: invalid types 'int[long long int]' for array subscript
   86 |                 if(t[i][j] == LLONG_MAX) t[ni][nj] = 1;
      |                                           ^
mecho.cpp:87:23: error: invalid types 'int[long long int]' for array subscript
   87 |                 else t[ni][nj]=t[i][j]+1;
      |                       ^
mecho.cpp:87:33: error: invalid types 'int[std::tuple_element<0, std::pair<long long int, long long int> >::type {aka long long int}]' for array subscript
   87 |                 else t[ni][nj]=t[i][j]+1;
      |                                 ^
mecho.cpp:93:44: error: invalid types 'int[long long int]' for array subscript
   93 |         for (int j = 0 ; j < n ; j++) if (t[i][j] == 0) t[i][j] = LLONG_MAX;
      |                                            ^
mecho.cpp:93:58: error: invalid types 'int[long long int]' for array subscript
   93 |         for (int j = 0 ; j < n ; j++) if (t[i][j] == 0) t[i][j] = LLONG_MAX;
      |                                                          ^