#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('R') != 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 |
2 ms |
1876 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
3284 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
852 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
1236 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
852 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
852 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
2004 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
1876 KB |
Output isn't correct |
17 |
Incorrect |
2 ms |
1876 KB |
Output isn't correct |
18 |
Incorrect |
4 ms |
3284 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1492 KB |
Output isn't correct |
2 |
Incorrect |
8 ms |
9888 KB |
Output isn't correct |
3 |
Incorrect |
76 ms |
97424 KB |
Output isn't correct |
4 |
Incorrect |
17 ms |
23068 KB |
Output isn't correct |
5 |
Incorrect |
40 ms |
54908 KB |
Output isn't correct |
6 |
Incorrect |
218 ms |
156396 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
1620 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
1492 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
852 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
1620 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
468 KB |
Output isn't correct |
13 |
Incorrect |
8 ms |
9888 KB |
Output isn't correct |
14 |
Incorrect |
5 ms |
5996 KB |
Output isn't correct |
15 |
Incorrect |
5 ms |
6500 KB |
Output isn't correct |
16 |
Incorrect |
3 ms |
4276 KB |
Output isn't correct |
17 |
Incorrect |
18 ms |
25060 KB |
Output isn't correct |
18 |
Incorrect |
16 ms |
24704 KB |
Output isn't correct |
19 |
Incorrect |
16 ms |
23132 KB |
Output isn't correct |
20 |
Incorrect |
20 ms |
21344 KB |
Output isn't correct |
21 |
Incorrect |
42 ms |
56796 KB |
Output isn't correct |
22 |
Incorrect |
40 ms |
54924 KB |
Output isn't correct |
23 |
Incorrect |
36 ms |
47384 KB |
Output isn't correct |
24 |
Incorrect |
42 ms |
55384 KB |
Output isn't correct |
25 |
Incorrect |
71 ms |
97360 KB |
Output isn't correct |
26 |
Runtime error |
752 ms |
1048576 KB |
Execution killed with signal 9 |
27 |
Incorrect |
928 ms |
748128 KB |
Output isn't correct |
28 |
Incorrect |
248 ms |
157384 KB |
Output isn't correct |
29 |
Incorrect |
238 ms |
176448 KB |
Output isn't correct |
30 |
Incorrect |
270 ms |
160320 KB |
Output isn't correct |
31 |
Incorrect |
48 ms |
63424 KB |
Output isn't correct |
32 |
Incorrect |
77 ms |
98156 KB |
Output isn't correct |