답안 #556761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556761 2022-05-03T21:55:03 Z Hanksburger Tracks in the Snow (BOI13_tracks) C++17
80.3125 / 100
828 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
#define si short int
#define pii pair<si, si>
#define fi first
#define se second
pii dir[4]={{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
vector<pii> vec, tmp;
string a[4001];
si n, m;
void dfs(pii u)
{
	char x=a[u.fi][u.se];
	a[u.fi][u.se]='.';
	for (pii i:dir)
	{
		pii v=u;
		v.fi+=i.fi;
		v.se+=i.se;
		if (a[v.fi][v.se]!='.')
		{
			if (a[v.fi][v.se]==x)
				dfs(v);
			else
				tmp.push_back(v);
		}
	}
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for (si i=0; i<=m+1; i++)
		a[0].push_back('.');
	for (si i=1; i<=n; i++)
	{
		a[i].push_back('.');
		for (si j=1; j<=m; j++)
		{
			char x;
			cin >> x;
			a[i].push_back(x);
		}
		a[i].push_back('.');
	}
	for (si i=0; i<=m+1; i++)
		a[n+1].push_back('.');
	int ans=0;
	tmp.push_back({1, 1});
	while (!tmp.empty())
	{
		vec=tmp;
		tmp.clear();
		for (pii u:vec)
			dfs(u);
		ans++;
	}
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1236 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 9 ms 1876 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 1108 KB Output is correct
12 Correct 7 ms 724 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 15 ms 1132 KB Output is correct
16 Correct 19 ms 1264 KB Output is correct
17 Correct 10 ms 980 KB Output is correct
18 Correct 10 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 59 ms 3020 KB Output is correct
3 Runtime error 312 ms 61752 KB Execution killed with signal 11
4 Correct 90 ms 7884 KB Output is correct
5 Correct 283 ms 12368 KB Output is correct
6 Runtime error 312 ms 61720 KB Execution killed with signal 11
7 Runtime error 2 ms 724 KB Execution killed with signal 11
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 980 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 59 ms 3012 KB Output is correct
14 Correct 33 ms 2268 KB Output is correct
15 Correct 28 ms 2516 KB Output is correct
16 Correct 32 ms 1404 KB Output is correct
17 Correct 150 ms 8516 KB Output is correct
18 Correct 111 ms 8228 KB Output is correct
19 Correct 92 ms 7824 KB Output is correct
20 Correct 100 ms 7416 KB Output is correct
21 Correct 247 ms 12764 KB Output is correct
22 Correct 275 ms 12316 KB Output is correct
23 Correct 303 ms 10432 KB Output is correct
24 Correct 242 ms 12692 KB Output is correct
25 Runtime error 313 ms 61768 KB Execution killed with signal 11
26 Runtime error 767 ms 1048576 KB Execution killed with signal 9
27 Runtime error 309 ms 61928 KB Execution killed with signal 11
28 Runtime error 309 ms 61896 KB Execution killed with signal 11
29 Runtime error 314 ms 61864 KB Execution killed with signal 11
30 Correct 828 ms 174452 KB Output is correct
31 Correct 758 ms 15072 KB Output is correct
32 Runtime error 315 ms 61848 KB Execution killed with signal 11