#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;
for (char& c : s)
if (c == '.')c = mat[0][0];
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2272 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
3412 KB |
Output isn't correct |
5 |
Incorrect |
8 ms |
6868 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
1620 KB |
Output isn't correct |
10 |
Incorrect |
5 ms |
4564 KB |
Output isn't correct |
11 |
Incorrect |
2 ms |
1236 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
980 KB |
Output isn't correct |
13 |
Incorrect |
7 ms |
6868 KB |
Output isn't correct |
14 |
Incorrect |
7 ms |
6868 KB |
Output isn't correct |
15 |
Incorrect |
10 ms |
6476 KB |
Output isn't correct |
16 |
Incorrect |
3 ms |
2260 KB |
Output isn't correct |
17 |
Incorrect |
14 ms |
12500 KB |
Output isn't correct |
18 |
Incorrect |
5 ms |
3412 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4044 KB |
Output isn't correct |
2 |
Incorrect |
93 ms |
96016 KB |
Output isn't correct |
3 |
Runtime error |
827 ms |
1048576 KB |
Execution killed with signal 9 |
4 |
Incorrect |
330 ms |
351360 KB |
Output isn't correct |
5 |
Incorrect |
870 ms |
917116 KB |
Output isn't correct |
6 |
Incorrect |
238 ms |
161424 KB |
Output isn't correct |
7 |
Incorrect |
5 ms |
4300 KB |
Output isn't correct |
8 |
Incorrect |
4 ms |
4052 KB |
Output isn't correct |
9 |
Incorrect |
4 ms |
4052 KB |
Output isn't correct |
10 |
Incorrect |
3 ms |
3536 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
5460 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
2728 KB |
Output isn't correct |
13 |
Incorrect |
112 ms |
95916 KB |
Output isn't correct |
14 |
Incorrect |
63 ms |
58924 KB |
Output isn't correct |
15 |
Incorrect |
86 ms |
100160 KB |
Output isn't correct |
16 |
Incorrect |
36 ms |
31776 KB |
Output isn't correct |
17 |
Incorrect |
278 ms |
262528 KB |
Output isn't correct |
18 |
Incorrect |
411 ms |
402224 KB |
Output isn't correct |
19 |
Incorrect |
384 ms |
351304 KB |
Output isn't correct |
20 |
Incorrect |
289 ms |
278036 KB |
Output isn't correct |
21 |
Incorrect |
715 ms |
787732 KB |
Output isn't correct |
22 |
Incorrect |
901 ms |
917164 KB |
Output isn't correct |
23 |
Incorrect |
518 ms |
501408 KB |
Output isn't correct |
24 |
Incorrect |
676 ms |
563944 KB |
Output isn't correct |
25 |
Runtime error |
654 ms |
1048576 KB |
Execution killed with signal 9 |
26 |
Correct |
77 ms |
79704 KB |
Output is correct |
27 |
Incorrect |
1039 ms |
754804 KB |
Output isn't correct |
28 |
Incorrect |
246 ms |
164324 KB |
Output isn't correct |
29 |
Incorrect |
301 ms |
183400 KB |
Output isn't correct |
30 |
Incorrect |
279 ms |
167164 KB |
Output isn't correct |
31 |
Incorrect |
60 ms |
68608 KB |
Output isn't correct |
32 |
Incorrect |
344 ms |
218428 KB |
Output isn't correct |