제출 #134840

#제출 시각아이디문제언어결과실행 시간메모리
134840CaroLindaTracks in the Snow (BOI13_tracks)C++14
89.06 / 100
2060 ms183344 KiB
#include <bits/stdc++.h>

#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair

const int inf = 0x3f3f3f3f ;
const int MAXN = 4010 ;

using namespace std ;

int n , m ;
int dx[4] = {1,0,-1,0} , dy[4] = {0,1,0,-1} ;
int d[MAXN][MAXN] ;
int adj[MAXN][MAXN][4] ;
char mat[MAXN][MAXN] ;
bool marc[MAXN][MAXN] ;
deque<pii> fila ;

bool valid(int x, int y) { return (x>=0 && x<n && y>=0 && y<m) ; }

int main()
{
	scanf("%d%d",&n,&m) ;
	lp(i,0,n)
		lp(j,0,m) 
			scanf(" %c", &mat[i][j]) ;

	fila.push_front(mk(0,0)) ;
	d[0][0] = 1 ;
	int ans = 1 ;

	while(!fila.empty())
	{
		pii p = fila.front() ;

		fila.pop_front() ;

		marc[p.ff][p.ss] = true ;

		lp(i,0,4)
		{
			int x = p.ff+dx[i] , y = p.ss+dy[i] ;
			
			if(!valid(x,y) || mat[x][y] =='.' || marc[x][y]) continue ;

			d[x][y] = d[p.ff][p.ss] ;

			if(mat[x][y] == mat[p.ff][p.ss])
				fila.push_front(mk(x,y)) ;

			else fila.push_back(mk(x,y)) , d[x][y] ++ ;

			ans = max(ans, d[x][y]) ;
		}
	}

	printf("%d\n", ans ) ;
}

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp: In function 'int main()':
tracks.cpp:28: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:31:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c", &mat[i][j]) ;
    ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...