Submission #390308

#TimeUsernameProblemLanguageResultExecution timeMemory
390308idontreallyknowDango Maker (JOI18_dango_maker)C++17
100 / 100
912 ms112076 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<class A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}; template<class A, class B> ostream& operator<<(ostream &cout, const pair<A,B> &x) {return cout << "(" <<x.first << ", " << x.second << ")";}; template<class T> void pv(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) cerr << *i << " "; cerr << "]\n";} void _print() {cerr << "]\n";} template<class T, class... V> void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);} #define debug(x...) cerr << "[" << #x << "] = [", _print(x) #define fi first #define se second #define SZ(x) (int)((x).size()) #define pii pair<int,int> int n,m; string grid[3000]; bool exist(int a, int b, int c) { if (a < 0 || a >= n || b < 0 || b >= m) return false; if (c == 0) { if (a-1 >= 0 && a+1 < n && grid[a-1][b] == 'R' && grid[a][b] == 'G' && grid[a+1][b] == 'W') return true; } else { if (b-1 >= 0 && b+1 < m && grid[a][b-1] == 'R' && grid[a][b] == 'G' && grid[a][b+1] == 'W') return true; } return false; } vector<pii> diag[6005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int q = 0; q < n; q++) cin >> grid[q]; for (int q = 0; q < n; q++) { for (int w = 0; w < m; w++) { diag[q+w].emplace_back(q,w); } } int ans = 0; for (int q = 0; q < n+m-1; q++) { vector<vector<int>> dp(SZ(diag[q])+3, vector<int>(2)); for (int w = 2; w <= SZ(diag[q])+1; w++) { int x = diag[q][w-2].fi, y = diag[q][w-2].se; dp[w][0] = dp[w-1][0]; dp[w][1] = dp[w-1][1]; if (exist(x,y,0)) dp[w][0] = max(dp[w][0], max(dp[w-1][0], dp[w-2][1])+1); if (exist(x,y,1)) dp[w][1] = max(dp[w][1], max(dp[w-2][0], dp[w-1][1])+1); } ans += max(dp[SZ(diag[q])+1][0], dp[SZ(diag[q])+1][1]); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...