Submission #893022

#TimeUsernameProblemLanguageResultExecution timeMemory
893022NurislamDango Maker (JOI18_dango_maker)C++14
100 / 100
251 ms63832 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() //~ #define int long long ///* __ __ __ */ ///* ====== _ /| /| __ _ / | | /| | @ | | | | / /| |\ | / | | @ | / */ ///* \- || |_| |_ / |/ | | | |_ |- | |--| /-| | | \ \ |==| |- /=| | \ | | |--| | |- */ ///* || | | |_ / | |__| _| |_ \__ | | / | |__ | __| | | | \ / | | \| \__ | | | | \ */ ///* typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vii; void solve(){ int n,m; cin >> n >> m; char a[n+5][m+5]; vector<vi> di(n+m+7); for (int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> a[i][j]; di[i+j].pb(i); } } int ans = 0; for (int i = 2; i <= n+m; i++){ int dp[di[i].size()+6][8]; int nm = di[i].size(); memset(dp, 0ll, sizeof(dp)); for(int j = 1; j <= nm; j++){ int x = di[i][j-1], y = i-di[i][j-1]; dp[j][0]=max({dp[j-1][0],dp[j-1][1],dp[j-1][2]}); if(a[x-1][y]=='R' && a[x][y]=='G' && a[x+1][y]=='W')dp[j][1]=max(dp[j-1][1],dp[j-1][0])+1; if(a[x][y-1]=='R' && a[x][y]=='G' && a[x][y+1]=='W')dp[j][2]=max(dp[j-1][2],dp[j-1][0])+1; } ans += max({dp[nm][0],dp[nm][1],dp[nm][2]}); } cout << ans << '\n'; } main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int test = 1; //~ cin >> test; while(test--){ solve(); } }

Compilation message (stderr)

dango_maker.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...