#include<bits/stdc++.h>
using namespace std;
const int N=2e3+1;
char a[N][N];
int xx[4]={0,0,1,-1};
int yy[4]={1,-1,0,0};
bool vis[N][N];
void dfs(int py, int px, char c){
a[py][px]='?';
vis[py][px]=1;
for(int i=0;i<4;i++){
if((a[py+yy[i]][px+xx[i]]=='?' or a[py+yy[i]][px+xx[i]]==c) and vis[py+yy[i]][px+xx[i]]==0){
dfs(py+yy[i],px+xx[i],c);
}
}
}
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
int cnt=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='F' or a[i][j]=='R'){
for(int x=1;x<=n;x++){
for(int y=1;y<=m;y++)vis[x][y]=0;
}
dfs(i,j,a[i][j]);
cnt++;
i=1;
j=1;
}
}
}
cout<<cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
22680 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2648 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Correct |
20 ms |
15964 KB |
Output is correct |
5 |
Incorrect |
39 ms |
7516 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
8 |
Correct |
1 ms |
2908 KB |
Output is correct |
9 |
Incorrect |
2 ms |
4700 KB |
Output isn't correct |
10 |
Incorrect |
26 ms |
7236 KB |
Output isn't correct |
11 |
Correct |
6 ms |
9564 KB |
Output is correct |
12 |
Correct |
35 ms |
11608 KB |
Output is correct |
13 |
Incorrect |
40 ms |
7508 KB |
Output isn't correct |
14 |
Incorrect |
38 ms |
7516 KB |
Output isn't correct |
15 |
Correct |
203 ms |
9424 KB |
Output is correct |
16 |
Correct |
139 ms |
22608 KB |
Output is correct |
17 |
Incorrect |
266 ms |
10840 KB |
Output isn't correct |
18 |
Correct |
20 ms |
15948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
11864 KB |
Execution killed with signal 11 |
2 |
Execution timed out |
2087 ms |
14472 KB |
Time limit exceeded |
3 |
Runtime error |
262 ms |
19696 KB |
Execution killed with signal 11 |
4 |
Execution timed out |
2058 ms |
23732 KB |
Time limit exceeded |
5 |
Runtime error |
202 ms |
17748 KB |
Execution killed with signal 11 |
6 |
Runtime error |
259 ms |
19792 KB |
Execution killed with signal 11 |
7 |
Runtime error |
7 ms |
11864 KB |
Execution killed with signal 11 |
8 |
Runtime error |
7 ms |
11864 KB |
Execution killed with signal 11 |
9 |
Incorrect |
27 ms |
2968 KB |
Output isn't correct |
10 |
Incorrect |
36 ms |
2796 KB |
Output isn't correct |
11 |
Runtime error |
7 ms |
11868 KB |
Execution killed with signal 11 |
12 |
Incorrect |
76 ms |
5528 KB |
Output isn't correct |
13 |
Execution timed out |
2029 ms |
14372 KB |
Time limit exceeded |
14 |
Execution timed out |
2045 ms |
11604 KB |
Time limit exceeded |
15 |
Execution timed out |
2019 ms |
8044 KB |
Time limit exceeded |
16 |
Execution timed out |
2058 ms |
11036 KB |
Time limit exceeded |
17 |
Runtime error |
134 ms |
15640 KB |
Execution killed with signal 11 |
18 |
Execution timed out |
2045 ms |
12376 KB |
Time limit exceeded |
19 |
Execution timed out |
2065 ms |
23820 KB |
Time limit exceeded |
20 |
Execution timed out |
2016 ms |
13248 KB |
Time limit exceeded |
21 |
Runtime error |
192 ms |
17784 KB |
Execution killed with signal 11 |
22 |
Runtime error |
195 ms |
17832 KB |
Execution killed with signal 11 |
23 |
Runtime error |
220 ms |
17952 KB |
Execution killed with signal 11 |
24 |
Runtime error |
187 ms |
17560 KB |
Execution killed with signal 11 |
25 |
Runtime error |
260 ms |
19876 KB |
Execution killed with signal 11 |
26 |
Runtime error |
222 ms |
18852 KB |
Execution killed with signal 11 |
27 |
Runtime error |
256 ms |
19796 KB |
Execution killed with signal 11 |
28 |
Runtime error |
272 ms |
19988 KB |
Execution killed with signal 11 |
29 |
Runtime error |
254 ms |
19792 KB |
Execution killed with signal 11 |
30 |
Runtime error |
259 ms |
20244 KB |
Execution killed with signal 11 |
31 |
Runtime error |
205 ms |
18204 KB |
Execution killed with signal 11 |
32 |
Runtime error |
265 ms |
20000 KB |
Execution killed with signal 11 |