#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<string> mat(n);
string res;
for (string& s : mat) {
cin >> s;
res += s;
}
vector vis(n, vector(m, 0));
auto dfs = [&](auto &dfs, int i, int j)-> void {
if (i < 0 || i >= n || j < 0 || j >= m) return;
if (vis[i][j]) return;
if (mat[i][j] != mat[0][0]) return;
vis[i][j] = 1;
dfs(dfs, i+1, j);
dfs(dfs, i-1, j);
dfs(dfs, i, j+1);
dfs(dfs, i, j-1);
};
int r = res.find('R') != string::npos;
int f = res.find('F') != string::npos;
if (f&&r) {
dfs(dfs, 0, 0);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (!vis[i][j] && mat[i][j] == mat[0][0]) { f = 2; break; }
}
}
}
cout << r+f<< '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2128 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
3412 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
1228 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
976 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
980 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
2124 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
2120 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
2128 KB |
Output isn't correct |
18 |
Incorrect |
4 ms |
3412 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1620 KB |
Output isn't correct |
2 |
Incorrect |
9 ms |
10316 KB |
Output isn't correct |
3 |
Incorrect |
81 ms |
98264 KB |
Output isn't correct |
4 |
Incorrect |
21 ms |
23412 KB |
Output isn't correct |
5 |
Incorrect |
48 ms |
55544 KB |
Output isn't correct |
6 |
Incorrect |
220 ms |
157124 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
1620 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
584 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
1620 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
13 |
Incorrect |
9 ms |
10292 KB |
Output isn't correct |
14 |
Incorrect |
6 ms |
6220 KB |
Output isn't correct |
15 |
Incorrect |
6 ms |
6748 KB |
Output isn't correct |
16 |
Incorrect |
5 ms |
4636 KB |
Output isn't correct |
17 |
Incorrect |
30 ms |
25448 KB |
Output isn't correct |
18 |
Incorrect |
22 ms |
25028 KB |
Output isn't correct |
19 |
Incorrect |
19 ms |
23492 KB |
Output isn't correct |
20 |
Incorrect |
18 ms |
21692 KB |
Output isn't correct |
21 |
Incorrect |
46 ms |
57516 KB |
Output isn't correct |
22 |
Incorrect |
44 ms |
55536 KB |
Output isn't correct |
23 |
Incorrect |
43 ms |
48000 KB |
Output isn't correct |
24 |
Incorrect |
44 ms |
56128 KB |
Output isn't correct |
25 |
Incorrect |
70 ms |
98092 KB |
Output isn't correct |
26 |
Correct |
69 ms |
74532 KB |
Output is correct |
27 |
Incorrect |
874 ms |
747180 KB |
Output isn't correct |
28 |
Incorrect |
214 ms |
156432 KB |
Output isn't correct |
29 |
Incorrect |
261 ms |
175468 KB |
Output isn't correct |
30 |
Incorrect |
235 ms |
159364 KB |
Output isn't correct |
31 |
Incorrect |
50 ms |
62896 KB |
Output isn't correct |
32 |
Incorrect |
67 ms |
97344 KB |
Output isn't correct |