# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
255628 | tleontest1 | Dango Maker (JOI18_dango_maker) | C++17 | 1507 ms | 18272 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.
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 3005;
const lo mod = 1000000007;
int n,m,b[li],a[li],flag,t,vis[li][li],vis1[li][li],visit[li][li];
int ans;
char c[li][li];
string s;
vector<int> v;
int main(void){
scanf("%d %d",&n,&m);
FOR{
for(int j=1;j<=m;j++){
scanf(" %c",&c[i][j]);
}
}
FOR{
for(int j=1;j<=m;j++){
if(c[i][j]!='G')continue;
vector<PII> vec;
vector<PII> dp;
for(int k=0;k<j;k++){
if(k+i>n)continue;
if(c[i+k][j-k]=='G'){
vec.pb({i+k,j-k});
}
else break;
}
for(int i=0;i<(int)vec.size()+10;i++)dp.pb({0,0});
for(int i=(int)vec.size()-1;i>=0;i--){
dp[i].fi=max(dp[i+1].fi,dp[i+2].se)+(c[vec[i].fi][vec[i].se-1]=='R' && c[vec[i].fi][vec[i].se+1]=='W'?1:0);
dp[i].se=max(dp[i+1].se,dp[i+2].fi)+(c[vec[i].fi-1][vec[i].se]=='R' && c[vec[i].fi+1][vec[i].se]=='W'?1:0);
c[vec[i].fi][vec[i].se]='.';
}
ans+=max(dp[0].fi,dp[0].se);
}
}
printf("%d\n",ans);
return 0;
}
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... |