#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;
}
assert(mat[0][0] != '.');
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2128 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
4 |
Incorrect |
5 ms |
3412 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
968 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
324 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 |
3 ms |
1236 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
972 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 |
3 ms |
2164 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
2132 KB |
Output isn't correct |
18 |
Incorrect |
5 ms |
3412 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1620 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
10296 KB |
Output isn't correct |
3 |
Incorrect |
100 ms |
102648 KB |
Output isn't correct |
4 |
Incorrect |
19 ms |
23184 KB |
Output isn't correct |
5 |
Incorrect |
50 ms |
55264 KB |
Output isn't correct |
6 |
Incorrect |
264 ms |
156868 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
1620 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
1608 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
980 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
1616 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
13 |
Incorrect |
9 ms |
10140 KB |
Output isn't correct |
14 |
Incorrect |
8 ms |
5996 KB |
Output isn't correct |
15 |
Incorrect |
6 ms |
6628 KB |
Output isn't correct |
16 |
Incorrect |
6 ms |
4468 KB |
Output isn't correct |
17 |
Incorrect |
23 ms |
25128 KB |
Output isn't correct |
18 |
Incorrect |
21 ms |
24728 KB |
Output isn't correct |
19 |
Incorrect |
22 ms |
23216 KB |
Output isn't correct |
20 |
Incorrect |
18 ms |
21448 KB |
Output isn't correct |
21 |
Incorrect |
57 ms |
57204 KB |
Output isn't correct |
22 |
Incorrect |
51 ms |
55300 KB |
Output isn't correct |
23 |
Incorrect |
50 ms |
47756 KB |
Output isn't correct |
24 |
Incorrect |
67 ms |
55864 KB |
Output isn't correct |
25 |
Incorrect |
97 ms |
102500 KB |
Output isn't correct |
26 |
Correct |
71 ms |
73788 KB |
Output is correct |
27 |
Incorrect |
1074 ms |
747344 KB |
Output isn't correct |
28 |
Incorrect |
262 ms |
158124 KB |
Output isn't correct |
29 |
Incorrect |
293 ms |
178264 KB |
Output isn't correct |
30 |
Incorrect |
321 ms |
162644 KB |
Output isn't correct |
31 |
Incorrect |
61 ms |
65736 KB |
Output isn't correct |
32 |
Incorrect |
105 ms |
102368 KB |
Output isn't correct |