제출 #984007

#제출 시각아이디문제언어결과실행 시간메모리
984007irmuunDango Maker (JOI18_dango_maker)C++17
33 / 100
353 ms262144 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,m; cin>>n>>m; char s[n+5][m+5]; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin>>s[i][j]; } } vector<vector<int>>v[n+m+5]; vector<int>u; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ u={0}; if((i>1&&s[i-1][j]=='R')&&s[i][j]=='G'&&(i<n&&s[i+1][j]=='W')){ u.pb(1); } if((j>1&&s[i][j-1]=='R')&&s[i][j]=='G'&&(j<m&&s[i][j+1]=='W')){ u.pb(2); } v[i+j].pb(u); } } int ans=0; vector<int>dp(3),dp1(3); for(int i=2;i<=n+m;i++){ fill(all(dp),0); for(auto vec:v[i]){ for(int j=0;j<3;j++){ dp1[j]=dp[j]; dp[j]=0; } for(auto x:vec){ if(x==0){ dp[0]=max({dp1[0],dp1[1],dp1[2]}); } if(x==1){ dp[1]=max(dp1[0],dp1[1])+1; } if(x==2){ dp[2]=max(dp1[0],dp1[2])+1; } } } ans+=max({dp[0],dp[1],dp[2]}); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...