제출 #26484

#제출 시각아이디문제언어결과실행 시간메모리
26484samir_droubiTracks in the Snow (BOI13_tracks)C++14
0 / 100
0 ms17684 KiB
#include <bits/stdc++.h>
using namespace std;
const short int mxn=4005;
char g[mxn][mxn];
short int n,m;

short int dx[]={0,0,1,-1};
short int dy[]={1,-1,0,0};
bool check(short int x,short int y)
{
	return x>=0&&x<n&&y>=0&&y<m;
}
char ty;
short int c=0;
vector<pair<short int,short int> >v;
vector<pair<short int,short int> >vv;
void dfs(short int x,short int y)
{
	++c;
	g[x][y]='.';
	for(short int i=0;i<4;++i)
	{
		short int xx=x+dx[i];
		short int yy=y+dy[i];
		if(!check(xx,yy))continue;
		if(g[xx][yy]!=ty)
		{
			vv.push_back({xx,yy});
			continue;
		}
		dfs(xx,yy);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	short int cnt=n*m;
	for(short int i=0;i<n;++i)scanf("%s",&g[i]);
	for(short int i=0;i<n;++i)
	{
		for(short int j=0;j<m;++j)
			if(g[i][j]=='.')
				--cnt;
	}
	v.push_back({0,0});
	short int ans=0;
	while(c!=cnt)
	{
		for(short int i=0;i<v.size();++i)
		{
			short int x=v[i].first;
			short int y=v[i].second;
			if(g[x][y]=='.')continue;
			ty=g[x][y];
			dfs(x,y);
		}
		v=vv;
		vv.clear();
		++ans;
	}
	printf("%d\n",ans);
	return 0;
}

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

tracks.cpp: In function 'int main()':
tracks.cpp:36:20: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'short int*' [-Wformat=]
  scanf("%d%d",&n,&m);
                    ^
tracks.cpp:36:20: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'short int*' [-Wformat=]
tracks.cpp:38:44: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[4005]' [-Wformat=]
  for(short int i=0;i<n;++i)scanf("%s",&g[i]);
                                            ^
tracks.cpp:49:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(short int i=0;i<v.size();++i)
                      ^
tracks.cpp:36:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
tracks.cpp:38:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(short int i=0;i<n;++i)scanf("%s",&g[i]);
                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...