# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201342 | abil | Dango Maker (JOI18_dango_maker) | C++14 | 5 ms | 380 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
//#define int long long
using namespace std;
const int N = (3e3 + 12);
const int mod = (1e9 + 7);
const int inf = (1e9 + 7);
int dp[N][N];
char a[N][N];
main(){
int n, m;
scanf("%d%d", &n, &m);
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
scanf(" %c", &a[i][j]);
}
}
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
int x = 0, y = 0;
if(j >= 3){
if(a[i][j] == 'W' && a[i][j - 1] == 'G' && a[i][j - 2] == 'R'){
y++;
}
}
if(i >= 3){
if(a[i][j] == 'W' && a[i - 1][j] == 'G' && a[i - 2][j] == 'R'){
x++;
}
}
dp[i][j] = max(dp[i - 1][j] + x + dp[i][j - 1] - dp[i - 1][j - 1], dp[i][j - 1] + y + dp[i - 1][j] - dp[i - 1][j - 1]);
}
}
int cnt = 0;
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
if(a[i][j] == 'R' && a[i][j + 1] == 'G' && a[i][j + 2] == 'W' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W'){
cnt++;
}
}
}
cout << dp[n][m] - cnt;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |