Submission #969453

#TimeUsernameProblemLanguageResultExecution timeMemory
969453batsukh2006Dango Maker (JOI18_dango_maker)C++17
100 / 100
788 ms18884 KiB
#include<iostream> #include<stdio.h> #include<math.h> #include<map> #include<string> #include<algorithm> #include<vector> #include<string.h> #include<utility> #include<set> #include<cmath> #include<queue> #include<deque> #include<functional> #include<stack> #include<limits.h> #include<iomanip> #include<unordered_map> #include<numeric> #include<tuple> using namespace std; #define MOD 1000000007 #define int long long #define endl '\n' void solve(){ int n,m; cin>>n>>m; vector<vector<char> > a(n+1,vector<char>(m+1)); for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ cin>>a[i][j]; } } int ans=0; for(int z=2; z<=n+m; z++){ int j=min(m,z-1),i=z-j; vector<vector<int> > dp(n+1,vector<int>(3)); while(j>=1&&i<=n){ dp[i][0]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]}); if(a[i][j]=='G'){ if(j>1&&j<m){ if(a[i][j-1]=='R'&&a[i][j+1]=='W'){ dp[i][1]=max(dp[i-1][0],dp[i-1][1])+1; } } if(i>1&&i<n){ if(a[i-1][j]=='R'&&a[i+1][j]=='W'){ dp[i][2]=max(dp[i-1][0],dp[i-1][2])+1; } } } i++,j--; } ans+=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]}); } cout<<ans; } signed main(){ // freopen("248.in", "r", stdin); // freopen("248.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--){ solve(); cout<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...