이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
//#include "grader.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
const int N = 3e3 + 10;
int dp[N][3];
char c[N][N];
void solve() {
int n, m; cin >> n >> m;
for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) cin >> c[i][j];
vector<pii> v;
int ans = 0;
for (int i = 1; i <= n; ++i) v.pb({i, 1});
for (int j = 2; j <= m; ++j) v.pb({n, j});
for (auto [x, y] : v) {
memset(dp, 0, sizeof(dp));
int cur = 0;
for (; x >= 1 && y <= m; --x, ++y) {
dp[y][0] = dp[y-1][0];
if (y >= 3 && c[x][y] == 'W' && c[x][y-1] == 'G' && c[x][y-2] == 'R') {
dp[y][1] = max(dp[y][1], max(dp[y-1][1], dp[y-2][1])+1);
dp[y][1] = max(dp[y][1], dp[y-3][0]+1);
}
if (x >= 3 && c[x][y] == 'W' && c[x-1][y] == 'G' && c[x-2][y] == 'R') {
dp[y][2] = max(dp[y][2], dp[y-1][0]+1);
}
dp[y][0] = max(dp[y][0], max(dp[y][1], dp[y][2]));
cur = max(cur, dp[y][0]);
}
ans += cur;
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
dango_maker.cpp: In function 'void solve()':
dango_maker.cpp:24:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
24 | for (auto [x, y] : v) {
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |