# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
467454 | Killer2501 | Dango Maker (JOI18_dango_maker) | C++14 | 1 ms | 460 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 ll long long
#define pb push_back
#define task "262144"
#define pll pair<ll, ll>
#define pi pair<ll, pll>
#define fi first
#define se second
using namespace std;
const ll mod = 1e15;
const ll N = 3e3+5;
const int base = 313;
ll n, m, t, k, T, ans, tong, dp[N*2][3], a[N][N][3];
char c[N][N];
vector<pll> adj[N*2];
vector<ll> kq;
ll pw(ll k, ll n)
{
ll total = 1;
for(; n; n >>= 1)
{
if(n & 1)total = total * k % mod;
k = k * k % mod;
}
return total;
}
void sol()
{
cin >> n >> m;
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= m; j ++)cin >> c[i][j];
}
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= m; j ++)
{
a[i][j][1] = (c[i-1][j] == 'R' && c[i][j] && 'G' && c[i+1][j] == 'W');
a[i][j][2] = (c[i][j-1] == 'R' && c[i][j] && 'G' && c[i][j+1] == 'W');
adj[i+j].pb({i, j});
//if(a[i][j][1])cout << i <<" "<<j<<" "<<1<<'\n';
//if(a[i][j][2])cout << i <<" "<<j<<" "<<2<<'\n';
}
}
for(int i = 2; i <= m+n; i ++)
{
k = adj[i].size();
for(int j = 1; j <= k; j ++)
{
ll x = adj[i][j-1].fi, y = adj[i][j-1].se;
dp[j][0] = max(dp[j-1][0], max(dp[j-1][1], dp[j-1][2]));
for(int p = 1; p <= 2; p ++)
{
if(a[x][y][p])dp[j][p] = max(dp[j-1][p], dp[j-1][0]) + 1;
else dp[j][p] = 0;
}
}
ans += max(dp[k][0], max(dp[k][1], dp[k][2]));
}
cout << ans;
}
int main()
{
if(fopen(task".in", "r"))
{
freopen(task".in", "r", stdin);
freopen(task".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int ntest = 1;
//cin >> ntest;
while(ntest -- > 0)
sol();
}
/*
4 5 2
10 9 5 2
6 4 20 15
9 7 10 9
-1 -1 16 11
1 2 3
2 3 3
1 4 1
4 3 1
3 1 1
*/
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... |