Submission #133987

#TimeUsernameProblemLanguageResultExecution timeMemory
133987CaroLindaTracks in the Snow (BOI13_tracks)C++14
45.31 / 100
2107 ms638320 KiB
#include <bits/stdc++.h> #define MAXN 4010 #define lp(i,a,b) for(int i=a;i<b;i++) using namespace std ; int n , m ; int mat[MAXN][MAXN] ; int dx[4] = {1,0,-1,0} ; int dy[4] = {0,-1,0,1} ; bool valid(int x, int y) { return (x>=0 && x< n && y>=0 && y<m) ; } int tot = 0 ; int dfs(int x , int y , int busco) { tot ++ ; mat[x][y] = !busco ; lp(i,0,4) { int a = x + dx[i] ; int b = y+dy[i] ; if( !valid(a,b) || mat[a][b] != busco ) continue ; dfs(a,b,busco) ; } } int main() { scanf("%d%d", &n , &m ) ; lp(i,0,n) lp(j,0,m) { char c ; scanf(" %c", &c ) ; if(c=='.') mat[i][j] = -1 ; else mat[i][j] = (c=='R'?0:1); } int ant = 0 , animal = 0 ; while(true) { tot = 0 ; dfs(0,0,mat[0][0]) ; if( ant == tot ) break ; animal ++ ; ant = tot ; } printf("%d\n" , animal ) ; }

Compilation message (stderr)

tracks.cpp: In function 'int dfs(int, int, int)':
tracks.cpp:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
tracks.cpp: In function 'int main()':
tracks.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n , &m ) ;
  ~~~~~^~~~~~~~~~~~~~~~~~
tracks.cpp:43:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c", &c ) ;
    ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...