#include <bits/stdc++.h>
using namespace std;
int main()
{
long int wynik1=0, wynik2=0;
int M,N;
cin >> N >> M;
string kol[N];
bool uzy[N][M];
for(int i=0;i<N;i++)
{
cin >> kol[i];
for(int j=0;j<M;j++)
{
uzy[i][j]=0;
}
}
// najpierw probujemy wszystkie poziomo , a pozniej pionowo
for(int i=0;i<N;i++)
{
for(int j=0;j<M-2;j++)
{
if(kol[i][j]=='R' && kol[i][j+1]=='G' && kol[i][j+2]=='W')
{
wynik1++;
uzy[i][j]=1;
uzy[i][j+1]=1;
uzy[i][j+2]=1;
}
}
}
for(int i=0;i<N-2;i++)
{
for(int j=0;j<M;j++)
{
if(kol[i][j]=='R' && kol[i+1][j]=='G' && kol[i+2][j]=='W')
{
if(uzy[i][j]==0 && uzy[i+1][j]==0 && uzy[i+2][j]==0){wynik1++;}
}
}
}
//czyszzcenie
for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
{
uzy[i][j]=0;
}
}
// najpierw pionowo pozniej poziomo
for(int i=0;i<N-2;i++)
{
for(int j=0;j<M;j++)
{
if(kol[i][j]=='R' && kol[i+1][j]=='G' && kol[i+2][j]=='W')
{
wynik2++;
uzy[i][j]=1;
uzy[i+1][j]=1;
uzy[i+2][j]=1;
}
}
}
for(int i=0;i<N;i++)
{
for(int j=0;j<M-2;j++)
{
if(kol[i][j]=='R' && kol[i][j+1]=='G' && kol[i][j+2]=='W')
{
if(uzy[i][j]==0 && uzy[i][j+1]==0 && uzy[i][j+2]==0){wynik2++;}
}
}
}
cout << max(wynik1 , wynik2);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |