제출 #92331

#제출 시각아이디문제언어결과실행 시간메모리
92331karmaDango Maker (JOI18_dango_maker)C++11
33 / 100
270 ms44664 KiB
#include<bits/stdc++.h> #define For(i, a, b) for(int i = a, _b = b; i <= _b; ++i) #define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i) #define FileName "test" #define ll long long #define ld long double #define ull unsigned long long #define Print(x) cerr << #x << "is " << x << '\n'; #define pb push_back #define X first #define Y second //#define Karma using namespace std; template<typename T> inline void Cin(T &x) { char c; T sign = 1; x = 0; for (c = getchar(); c < '0' || c > '9'; c = getchar()) if (c == '-') sign = -1; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; x *= sign; } template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');} template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);} template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);} template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);} typedef pair<int, int> pii; typedef pair<ll, int> plli; const int N = 3e3 + 7; int n, m, res, f[N][3], ptr; bool p[N][N][3]; string s[N]; vector<pii> v; void Enter() { cin >> n >> m; For(i, 1, n) { cin >> s[i]; s[i] = ' ' + s[i]; } For(i, 1, n) { For(j, 1, m) { if(s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W') p[i][j][1] = 1; if(s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W') p[i][j][2] = 1; } } } void Solve() { v.resize(max(m, n) + 1); res = 0; For(i, 2, n + m) { int ptr = 0; For(j, 1, n) { int k = i - j; if(k > 0 && k <= m) v[++ptr] = {j, k}; } int ans = 0; memset(&f, 0, sizeof f); For(j, 1, ptr) { f[j][0] = max({f[j - 1][0], f[j - 1][1], f[j - 1][2]}); if(p[v[j].X][v[j].Y][1]) f[j][1] = max(f[j - 1][0], f[j - 1][1]) + 1; if(p[v[j].X][v[j].Y][2]) f[j][2] = max(f[j - 1][0], f[j - 1][2]) + 1; ans = max(ans, f[j][0]); } ans = max({ans, f[ptr][1], f[ptr][2]}); res += ans; } cout << res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef Karma freopen(FileName".inp", "r", stdin); freopen(FileName".out", "w", stdout); #endif // Karma Enter(); Solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...