Submission #251147

#TimeUsernameProblemLanguageResultExecution timeMemory
251147mat_vDango Maker (JOI18_dango_maker)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i)) #define mod 998244353 #define xx first #define yy second #define all(a) (a).begin(), (a).end() #define pb push_back #define ll long long #define pii pair<int,int> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less) mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int n,m; int mat[3005][3005]; bool moze[3005][3005][2]; int dp[3005][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; ff(i,1,n){ string x; cin >> x; ff(j,0,m - 1){ if(x[j] == 'R')mat[i][j + 1] = 0; else if(x[j] == 'G')mat[i][j + 1] = 1; else if(x[j] == 'W')mat[i][j + 1] = 2; } } ff(i,1,n){ ff(j,1,m){ if(mat[i][j] != 1)continue; if(mat[i][j - 1] == 0 && mat[i][j + 1] == 2){ moze[i][j][0] = 1; } if(mat[i - 1][j] == 0 && mat[i + 1][j] == 2){ moze[i][j][1] = 1; } } } int res = 0; ff(s,2,n + m){ ff(i,1,m)dp[i][0] = dp[i][1] = dp[i][2] = 0; int l = 1; if(s > n+1)l = s - n; int r = m; int poml = 1; if(s > m+1)poml = s-m; r = s - poml; dp[l][0] = 0; if(moze[s - l][l][0])dp[l][1] = 1; else dp[l][1] = -1e9; if(moze[s - l][l][1])dp[l][2] = 1; else dp[l][2] = -1e9; ff(j,l + 1,r){ dp[j][0] = max(dp[j - 1][0], max(dp[j - 1][1], dp[j - 1][2])); dp[j][0] = max(dp[j][0], 0); dp[j][1] = dp[j][2] = -1e9; if(moze[s - j][j][0])dp[j][1] = max(dp[j - 1][0], dp[j - 1][1]) + 1; if(moze[s - j][j][1])dp[j][2] = max(dp[j - 1][0], dp[j - 1][2]) + 1; } res += max(dp[r][0], max(dp[r][1], dp[r][2])); } cout << res << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...