Submission #133986

# Submission time Handle Problem Language Result Execution time Memory
133986 2019-07-21T21:50:00 Z CaroLinda Tracks in the Snow (BOI13_tracks) C++14
34.375 / 100
1151 ms 11716 KB
#include <bits/stdc++.h>

#define MAXN 510
#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

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 time Memory Grader output
1 Correct 218 ms 11664 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 39 ms 8480 KB Output is correct
5 Correct 50 ms 1400 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 632 KB Output is correct
9 Correct 4 ms 504 KB Output is correct
10 Correct 53 ms 992 KB Output is correct
11 Correct 9 ms 2552 KB Output is correct
12 Correct 61 ms 4312 KB Output is correct
13 Correct 49 ms 1400 KB Output is correct
14 Correct 50 ms 1488 KB Output is correct
15 Correct 324 ms 3064 KB Output is correct
16 Correct 216 ms 11716 KB Output is correct
17 Correct 346 ms 4668 KB Output is correct
18 Correct 37 ms 8568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Incorrect 39 ms 1400 KB Output isn't correct
3 Incorrect 116 ms 1276 KB Output isn't correct
4 Incorrect 60 ms 1272 KB Output isn't correct
5 Incorrect 89 ms 1276 KB Output isn't correct
6 Incorrect 119 ms 1372 KB Output isn't correct
7 Incorrect 3 ms 1272 KB Output isn't correct
8 Runtime error 5 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Incorrect 8 ms 376 KB Output isn't correct
10 Incorrect 4 ms 376 KB Output isn't correct
11 Incorrect 10 ms 1272 KB Output isn't correct
12 Correct 1151 ms 1372 KB Output is correct
13 Incorrect 39 ms 1272 KB Output isn't correct
14 Incorrect 32 ms 1276 KB Output isn't correct
15 Incorrect 33 ms 1272 KB Output isn't correct
16 Incorrect 105 ms 1272 KB Output isn't correct
17 Incorrect 60 ms 1400 KB Output isn't correct
18 Incorrect 64 ms 1372 KB Output isn't correct
19 Incorrect 60 ms 1400 KB Output isn't correct
20 Incorrect 59 ms 1328 KB Output isn't correct
21 Incorrect 89 ms 1400 KB Output isn't correct
22 Incorrect 89 ms 1336 KB Output isn't correct
23 Incorrect 91 ms 1400 KB Output isn't correct
24 Runtime error 88 ms 2552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Incorrect 128 ms 1356 KB Output isn't correct
26 Correct 105 ms 1372 KB Output is correct
27 Runtime error 120 ms 2524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Incorrect 119 ms 1400 KB Output isn't correct
29 Incorrect 120 ms 1372 KB Output isn't correct
30 Incorrect 121 ms 1400 KB Output isn't correct
31 Incorrect 96 ms 1384 KB Output isn't correct
32 Runtime error 119 ms 2552 KB Execution killed with signal 11 (could be triggered by violating memory limits)