이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<string> plansza;
int64_t tab[3001][3001];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for(int i = 0; i < n; i++){
string s;
cin >> s;
plansza.push_back(s);
}
int64_t wyn = 0;
for(int i = n - 1; i >= 0; i--){
for(int j = m - 1; j >= 0; j--){
if(plansza[i][j] == 'R'){
if(i < n - 2){
if(plansza[i + 1][j] == 'G' && plansza[i + 2][j] == 'W'){
if(tab[i + 1][j] == 0){
if(tab[i + 2][j] == 0){
tab[i][j] = 1;
tab[i + 1][j] = j + i * 3001;
tab[i + 2][j] = j + i * 3001;
}else{
if(tab[i + 2][j - 1] == 0){
tab[i][j] = 1;
}
}
}else{
if(tab[i + 2][j] == 0){
tab[i + 1][j] = 0;
}
}
}
}
if(j < m - 2 && tab[i][j] == 0){
if(plansza[i][j + 1] == 'G' && plansza[i][j + 2] == 'W'){
tab[i][j] = 1;
tab[i][j + 1] = j + i * 3001;
tab[i][j + 2] = j + i * 3001;
}
}
int64_t jeden = 1;
wyn += min(jeden, tab[i][j]);
}
}
}
cout << wyn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |