Submission #254404

# Submission time Handle Problem Language Result Execution time Memory
254404 2020-07-30T00:13:44 Z oscarsierra12 Mecho (IOI09_mecho) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std ;
 
const int N = 1000 ;
 
string ma[N] ;
int dist[N][N], dist2[N][N] ;
int X [] = {0,0,-1,1}, Y[] = {1,-1,0,0} ;
int visi[N][N] ;
int main() {
   int n, s ;
   cin >> n >> s ;
   for ( int i = 0 ; i < n ; ++i ) cin >> ma[i] ;
   queue <pair<int,int>> bfs ;
   pair<int,int> bg, en ;
   for ( int i = 0 ; i < n ; ++i ) {
      for ( int j = 0 ;  j < n ; ++j ) {
          if ( ma[i][j] == 'H' ) bfs.push({i,j}), dist2[i][j] = 0, visi[i][j] = 1 ;
          if ( ma[i][j] == 'T'  ) visi[i][j] = 1 ;
          if ( ma[i][j] == 'M' ) bg = {i,j} ;
          if ( ma[i][j] == 'D' ) en = {i,j} ;
      }
   }
   while ( bfs.size() ) {
      pair<int,int> cur = bfs.front() ;
      bfs.pop() ;
      for ( int k = 0 ; k < 4 ; ++k ) {
         int nwx = X[k] + cur.first ;
         int nwy = Y[k] + cur.second ;
         if ( nwx < 0 || nwy < 0 || nwx >= n || nwy >= n || visi[nwx][nwy] ) continue ;
         visi[nwx][nwy] = 1 ;
         dist2[nwx][nwy] = 1 + dist2[cur.first][cur.second] ;
         bfs.push({nwx, nwy}) ; 
      }
   }
   int lw = 0, hg = 1000000000 ; 
   while ( lw <= hg ) {
      int mid = (lw+hg) / 2 ;
      memset ( visi, 0, sizeof visi ) ; 
      memset ( dist, 0, sizeof dist ) ; 
      bfs.push(bg) ;
      visi[bg.first][bg.second] = 1 ;
      while ( bfs.size() ) {
          pair<int,int> cur = bfs.front() ;
          bfs.pop() ;
          for ( int k = 0 ; k < 4 ; ++k ) {
             int nwx = X[k] + cur.first ;
             int nwy = Y[k] + cur.second ;
             if ( nwx < 0 || nwy < 0 || nwx >= n || nwy >= n || visi[nwx][nwy] || ma[nwx][nwy] == 'T' ) continue ;
             if ( (nwx != en.first || nwy != en.second) && (1 + dist[cur.first][cur.second]) / s + mid >= dist2[nwx][nwy] ) continue ;
             visi[nwx][nwy] = 1 ;
             dist[nwx][nwy] = 1 + dist[cur.first][cur.second] ;
             bfs.push({nwx, nwy}) ; 
          }
      }
      if ( visi[en.first][en.second] ) lw = mid+1 ;
      else hg = mid-1 ;
   }
   cout << hg << endl ;
}

Compilation message

mecho.cpp:50:38: error: stray '\302' in program
              if ( (nwx != en.first || nwy != en.second) && (1 + dist[cur.first][cur.second]) / s + mid >= dist2[nwx][nwy] ) continue ;
                                      ^
mecho.cpp:50:39: error: stray '\240' in program
              if ( (nwx != en.first || nwy != en.second) && (1 + dist[cur.first][cur.second]) / s + mid >= dist2[nwx][nwy] ) continue ;
                                       ^