Submission #602775

#TimeUsernameProblemLanguageResultExecution timeMemory
602775AA_SurelyDango Maker (JOI18_dango_maker)C++14
33 / 100
151 ms115232 KiB
#include <bits/stdc++.h> #define FOR(i, x, n) for(int i = x; i < n; i++) #define F0R(i, n) FOR(i, 0, n) #define ROF(i, x, n) for(int i = n - 1; i >= x; i--) #define R0F(i, n) ROF(i, 0, n) #define WTF cout << "WTF" << endl #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define F first #define S second #define PB push_back #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<int, PII> PPI; typedef vector<int> VI; typedef vector<LL> VLL; typedef vector<PII> VPII; typedef vector<PLL> VPLL; const int N = 3000 + 7; const int LOG = 20; const int INF = 1e9 + 7; int n,m; string pic[N]; int dp[N][N][3]; int main() { IOS; cin >> n >> m; FOR(i, 1, n + 1) { cin >> pic[i]; pic[i] = " " + pic[i]; } FOR(i, 1, n + 1) FOR(j, 1, m + 1) { dp[i][j][0] = max({dp[i - 1][j + 1][0], dp[i - 1][j + 1][1], dp[i - 1][j + 1][2]}); if(pic[i][j - 1] == 'R' && pic[i][j] == 'G' && pic[i][j + 1] == 'W') dp[i][j][1] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1]) + 1; if(pic[i - 1][j] == 'R' && pic[i][j] == 'G' && pic[i + 1][j] == 'W') dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][2]) + 1; } int ans = 0; FOR(i, 1, n + 1) ans += max({dp[i][1][0], dp[i][1][1], dp[i][1][2]}); FOR(j, 2, m + 1) ans += max({dp[n][j][0], dp[n][j][1], dp[n][j][2]}); cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...