#include<bits/stdc++.h>
using namespace std;
const int N=4e3+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=n;i>=1;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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
109 ms |
22404 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
4700 KB |
Output isn't correct |
4 |
Incorrect |
26 ms |
15956 KB |
Output isn't correct |
5 |
Incorrect |
4 ms |
6748 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
4700 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
4956 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
4700 KB |
Output isn't correct |
10 |
Incorrect |
28 ms |
7176 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
6236 KB |
Output isn't correct |
12 |
Incorrect |
35 ms |
11720 KB |
Output isn't correct |
13 |
Incorrect |
4 ms |
6744 KB |
Output isn't correct |
14 |
Incorrect |
4 ms |
6748 KB |
Output isn't correct |
15 |
Incorrect |
85 ms |
8840 KB |
Output isn't correct |
16 |
Incorrect |
118 ms |
22564 KB |
Output isn't correct |
17 |
Incorrect |
9 ms |
6752 KB |
Output isn't correct |
18 |
Incorrect |
19 ms |
15968 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
31580 KB |
Output isn't correct |
2 |
Execution timed out |
2060 ms |
18420 KB |
Time limit exceeded |
3 |
Incorrect |
509 ms |
32340 KB |
Output isn't correct |
4 |
Incorrect |
141 ms |
19372 KB |
Output isn't correct |
5 |
Incorrect |
284 ms |
27320 KB |
Output isn't correct |
6 |
Execution timed out |
2032 ms |
588800 KB |
Time limit exceeded |
7 |
Incorrect |
13 ms |
31832 KB |
Output isn't correct |
8 |
Incorrect |
7 ms |
31580 KB |
Output isn't correct |
9 |
Incorrect |
4 ms |
3160 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
2652 KB |
Output isn't correct |
11 |
Incorrect |
7 ms |
31580 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
4952 KB |
Output isn't correct |
13 |
Execution timed out |
2085 ms |
18696 KB |
Time limit exceeded |
14 |
Incorrect |
1062 ms |
14024 KB |
Output isn't correct |
15 |
Incorrect |
34 ms |
10840 KB |
Output isn't correct |
16 |
Incorrect |
1041 ms |
10196 KB |
Output isn't correct |
17 |
Execution timed out |
2073 ms |
22584 KB |
Time limit exceeded |
18 |
Incorrect |
135 ms |
19028 KB |
Output isn't correct |
19 |
Incorrect |
120 ms |
19372 KB |
Output isn't correct |
20 |
Incorrect |
117 ms |
17072 KB |
Output isn't correct |
21 |
Incorrect |
698 ms |
27876 KB |
Output isn't correct |
22 |
Incorrect |
312 ms |
27312 KB |
Output isn't correct |
23 |
Execution timed out |
2043 ms |
27104 KB |
Time limit exceeded |
24 |
Incorrect |
292 ms |
27560 KB |
Output isn't correct |
25 |
Incorrect |
513 ms |
32188 KB |
Output isn't correct |
26 |
Correct |
1401 ms |
990496 KB |
Output is correct |
27 |
Incorrect |
888 ms |
298476 KB |
Output isn't correct |
28 |
Execution timed out |
2048 ms |
782864 KB |
Time limit exceeded |
29 |
Execution timed out |
2090 ms |
862000 KB |
Time limit exceeded |
30 |
Execution timed out |
2124 ms |
935024 KB |
Time limit exceeded |
31 |
Execution timed out |
2067 ms |
161028 KB |
Time limit exceeded |
32 |
Incorrect |
1421 ms |
471888 KB |
Output isn't correct |