#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
int n, m;
vector<pair<int ,int>> v;int mx=0;
void b(string * s, int sh, int p, bool ch){
if(p==v.size()){
mx=max(mx, sh);
return;
}
int x=v[p].f, y=v[p].s;
if(y<m-2){
if(s[x][y+1]=='G'&&s[x][y+2]=='W'){
if(ch==0){
b(s, sh+1, p+1, ch);return;
}else{
if(x>0){
if(!(x<n-1&&s[x-1][y+1]=='R'&&s[x+1][y+1]=='W')&&!(x>2&&s[x-2][y+2]=='R'&&s[x-1][y+2]=='G')){
b(s, sh+1, p+1, ch);return;
}
}else{
b(s, sh+1, p+1, ch);return;
}
}
}
}
if(x<n-2){
if(s[x+1][y]=='G'&&s[x+2][y]=='W'){
if(ch==1){
b(s, sh+1, p+1, ch);return;
}else{
if(y>0){
if(!(y<m-1&&s[x+1][y-1]=='R'&&s[x+1][y+1]=='W')&&!(y>2&&s[x+2][y-2]=='R'&&s[x+2][y-1]=='G')){
b(s, sh+1, p+1, ch);return;
}
}else{
b(s, sh+1, p+1, ch);return;
}
}
}
}
b(s, sh, p+1, ch);
}
int main() {
cin >> n >> m;
string s[n];
for(int i=0; i<n; i++){
cin >> s[i];
for(int j=0; j<m; j++){
if(s[i][j]=='R'){
v.push_back({i, j});
}
}
}
b(s, 0, 0, 0);
b(s, 0, 0, 1);
cout << mx;
return 0;
}
Compilation message
dango_maker.cpp: In function 'void b(std::string*, int, int, bool)':
dango_maker.cpp:8:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | if(p==v.size()){
| ~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |