Submission #41590

#TimeUsernameProblemLanguageResultExecution timeMemory
41590TurysbekDango Maker (JOI18_dango_maker)C++14
13 / 100
2 ms756 KiB
// In the name of God #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define fi first #define se second #define pb push_back #define mp make_pair #define sz(a) int(a.size()) #define all(v) v.begin(), v.end() #define bpc(v) __builtin_popcountll(v) #define IOS ios_base :: sync_with_stdio(false); cin.tie(NULL); #define itr iterator #define rep(i, a, b) for (int i = a; i <= b; ++i) #define per(i, a, b) for (int i = a; i >= b; --i) #define ub upper_bound #define lb lower_bound const int N = 3e3 + 5; const int inf = 1e9 + 1; const int mod = 1e9 + 7; const double eps = 1e-15; const int pw = 257; int n, m, dp[N][N][2], ans; string s[N]; bool check(int i, int j, bool o) { if (!o) return (i + 2 <= n && s[i][j] == 'R' && s[i + 1][j] == 'G' && s[i + 2][j] == 'W'); else return (j + 2 <= m && s[i][j] == 'R' && s[i][j + 1] == 'G' && s[i][j + 2] == 'W'); } int main() { #ifdef Madi freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif IOS cin >> n >> m; rep(i, 1, n) { cin >> s[i]; s[i] = '$' + s[i]; } per(i, n, 1) { rep(j, 1, m) { dp[i][j][0] = max(dp[i][j][0], dp[i + 1][j - 1][0] + check(i, j, 0)); dp[i][j][1] = max(dp[i][j][1], max(dp[i + 1][j - 1][0], dp[i + 1][j - 1][1]) + check(i, j, 1)); if (i == 1 || j == m) ans += max(dp[i][j][0], dp[i][j][1]); //cout << i << ' ' << j << ' ' << dp[i][j][0] << ' ' << dp[i][j][1] << "\n"; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...