# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
210004 | kshitij_sodani | Dango Maker (JOI18_dango_maker) | C++17 | 498 ms | 44536 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 <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef int64_t llo;
#define a first
#define b second
#define endl "\n"
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
int it[n][m];
char s;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>s;
if(s=='R'){
it[i][j]=0;
}
else if(s=='G'){
it[i][j]=1;
}
else{
it[i][j]=2;
}
}
}
int tot=0;
for(int ii=0;ii<n+m-1;ii++){
vector<pair<int,int>> aa;
for(int jj=0;jj<ii+1;jj++){
int i,j;
j=jj;
i=ii-j;
int co=0;
int co2=0;
if(i>=n or j>=m){
continue;
}
int st=1;
int stt=1;
if(j>0 and it[i][j-1]==0 and j+1<m and it[i][j+1]==2 and it[i][j]==1){
co+=1;
}
if(i>0 and i+1<n and it[i-1][j]==0 and it[i+1][j]==2 and it[i][j]==1){
co2+=1;
}
aa.pb({co,co2});
}
pair<int,int> dp[aa.size()];
dp[0]=aa[0];
for(int k=1;k<aa.size();k++){
dp[k]=dp[k-1];
if(aa[k].a==1){
dp[k].a+=1;
if(k>1){
dp[k].a=max(dp[k].a,dp[k-2].b+1);
}
}
if(aa[k].b==1){
dp[k].b+=1;
if(k>1){
dp[k].b=max(dp[k].b,dp[k-2].a+1);
}
}
}
tot+=max(dp[aa.size()-1].a,dp[aa.size()-1].b);
}
cout<<tot<<endl;
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... |