제출 #939292

#제출 시각아이디문제언어결과실행 시간메모리
939292vjudge1Dango Maker (JOI18_dango_maker)C++17
100 / 100
291 ms159344 KiB
#include<bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; #define int ll typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define F first #define S second #define getlast(s) (*s.rbegin()) #define debg cout << "OK\n" const ld PI = 3.1415926535; const int N = 3000+1; const int M = 7e6 + 1; int mod = 998244353; const int infi = INT_MAX; const ll infl = LLONG_MAX; const int P = 31; int mult(int a, int b) { return a * 1LL * b % mod; } int sum(int a, int b) { if (a + b < 0) return a + b + mod; if (a + b >= mod) return a + b - mod; return a + b; } ll binpow(ll a, ll n) { if (n == 0) return 1; if (n % 2 == 1) { return binpow(a, n - 1) * a % mod; } else { ll b = binpow(a, n / 2); return b * b % mod; } } int n, m, l[N][N], r[N][N]; char c[N][N]; void solve(){ cin >> n >> m; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> c[i][j]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(i + 2 <= n){ if(c[i][j] == 'R' && c[i + 1][j] == 'G' && c[i + 2][j] == 'W') l[i][j] = 1; } if(j + 2 <= m){ if(c[i][j] == 'R' && c[i][j + 1] == 'G' && c[i][j + 2] == 'W') r[i][j] = 1; } } } int ans = 0; for(int s = 2; s <= n + m; s++){ vector<int> dpl(min(s + 1, m + 1), 0); vector<int> dpr(min(s + 1, m + 1), 0); for(int j = 1; j <= min(s, m); j++){ int i = s - j; if(i < 1 || i > n){ dpl[j] = dpl[j - 1]; dpr[j] = dpr[j - 1]; continue; } if(l[i][j]){ dpl[j] = dpl[j - 1] + 1; if(j - 3 >= 0) dpl[j] = max(dpl[j], dpr[j - 3] + 1); }else{ dpl[j] = dpl[j - 1]; } if(r[i][j]){ dpr[j] = max(dpr[j - 1], dpl[j - 1]) + 1; }else{ dpr[j] = dpr[j - 1]; } } ans += max(dpr[min(s, m)], dpl[min(s, m)]); } cout << ans << '\n'; } signed main() { mispertion; int t = 1; //cin >> t; while(t--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...