# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
914792 | May27_th | Dango Maker (JOI18_dango_maker) | C++17 | 2 ms | 2808 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 int64_t long long
#define double long double
using namespace std;
using type = int64_t;
const long long mod = 1000000007, inf = 1e18;
const int base = 33;
const int N = 2e5 + 10;
const int LG = 20;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void Minimize(int64_t &a, int64_t b) {if(b < a) a = b;}
void Maximize(int &a, int b) {if(b > a) a = b;}
void Add(int64_t& a, int64_t b) {a = a + b; a %= mod;}
void Dec(int64_t& a, int64_t b) {a = a - b + mod; a %= mod;}
int n, m; char d[3005][3005]; int f[3005][3004], add[3005][3005];
bool h(int i, int j)
{
return (d[i][j] == 'W') && (d[i][j - 1] == 'G') && (d[i][j - 2] == 'R');
}
bool v(int i, int j)
{
return (d[i][j] == 'W') && (d[i - 1][j] == 'G') && (d[i - 2][j] == 'R');
}
bool adhoc(int i, int j)
{
if(i < 3 || j < 3) return false;
bool flag = v(i, j - 2) & h(i - 2, j);
return flag;
}
void Solve(void)
{
/**
tim so cach xien que sao cho thu tu la R, G, W
**/
cin >> n >> m;
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
cin >> d[i][j];
}
}
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
if(h(i, j) && v(i + 2, j - 2)) add[i + 2][j] ++;
if(h(i, j) && v(i + 1, j - 1)) add[i + 1][j] ++;
}
}
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= m; j ++){
int bonus = 0;
if(h(i, j) || v(i, j)) bonus = 1;
f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + bonus - add[i][j];
//cout << f[i][j] << " ";
}
//cout << "\n";
}
cout << f[n][m];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
if(fopen("poetry.in", "r")){
freopen("poetry.in", "r", stdin);
freopen("poetry.out", "w", stdout);
}
if(fopen("A.inp", "r")){
freopen("A.inp", "r", stdin);
freopen("A.out", "w", stdout);
}
int tc = 1;
//cin >> tc;
while(tc --){
Solve();
}
}
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... |