#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int w,h;
vector<vector<int>>grid(w,vector<int>(h));
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
vector<vector<int>>vis(w,vector<int>(h,0));
void dfs(int x,int y){
vis[x][y]=1;
for(int i=0;i<4;i++){
int nx=x+dx[i];
int ny=y+dy[i];
if(nx>=0 && nx<w && ny>=0 && ny<h &&!vis[nx][ny]&& grid[nx][ny]==grid[x][y]){
dfs(nx,ny);
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>w>>h;
for(int i=0;i<w;i++){
for(int j=0;j<h;j++){
char x;
cin>>x;
grid[i][j]=x;
}
}
int ans=0;
for(int j=0;j<w;j++){
for(int i=0;i<h;i++){
if(!vis[j][i] &&(grid[j][i]=='R'||grid[j][i]=='F')){
dfs(j,i);
ans++;
}
}
}
cout<<ans<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
3 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
4 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
5 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
6 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 11 |
7 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
8 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
9 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 11 |
10 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
11 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
12 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
13 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
14 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
15 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
16 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
17 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
18 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
3 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
4 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
5 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
6 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
7 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
8 |
Runtime error |
0 ms |
464 KB |
Execution killed with signal 11 |
9 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
10 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
11 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
12 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
13 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
14 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
15 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
16 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
17 |
Runtime error |
0 ms |
468 KB |
Execution killed with signal 11 |
18 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
19 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
20 |
Runtime error |
1 ms |
472 KB |
Execution killed with signal 11 |
21 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
22 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
23 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
24 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
25 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
26 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
27 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
28 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 11 |
29 |
Runtime error |
0 ms |
612 KB |
Execution killed with signal 11 |
30 |
Runtime error |
1 ms |
476 KB |
Execution killed with signal 11 |
31 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
32 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |