QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#196654 | #3125. Dango Maker | Camillus | 0 | 1ms | 3480kb | C++20 | 2.5kb | 2023-10-01 21:08:02 | 2023-10-01 21:08:02 |
answer
#include <bits/stdc++.h>
using namespace std;
char t[3000][3000];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n, m;
cin >> n >> m;
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> t[i][j];
}
}
for (int a = 1; a <= n; a++) {
int x = a;
int y = 1;
vector<int> s;
while (1 <= x && x <= n && 1 <= y && y <= m) {
s.emplace_back(0);
if (t[x][y - 1] == 'R' && t[x][y] == 'G' && t[x][y + 1] == 'W') {
s.back() |= 1;
}
if (t[x - 1][y] == 'R' && t[x][y] == 'G' && t[x + 1][y] == 'W') {
s.back() |= 2;
}
x--, y++;
}
vector<vector<int>> dp(s.size(), vector<int>(3));
dp[0][1] = bool(s[0] & 1);
dp[0][2] = bool(s[0] & 2);
for (int i = 1; i < s.size(); i++) {
dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
if (s[i] & 1) {
dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + 1;
}
if (s[i] & 2) {
dp[i][2] = max(dp[i - 1][2], dp[i][0]) + 1;
}
}
ans += *max_element(dp.back().begin(), dp.back().end());
}
for (int b = 2; b <= m; b++) {
int x = n;
int y = b;
vector<int> s;
while (1 <= x && x <= n && 1 <= y && y <= m) {
s.emplace_back(0);
if (t[x][y - 1] == 'R' && t[x][y] == 'G' && t[x][y + 1] == 'W') {
s.back() |= 1;
}
if (t[x - 1][y] == 'R' && t[x][y] == 'G' && t[x + 1][y] == 'W') {
s.back() |= 2;
}
x--, y++;
}
vector<vector<int>> dp(s.size(), vector<int>(3));
dp[0][1] = bool(s[0] & 1);
dp[0][2] = bool(s[0] & 2);
for (int i = 1; i < s.size(); i++) {
dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
if (s[i] & 1) {
dp[i][1] = max(dp[i - 1][1], dp[i - 1][0]) + 1;
}
if (s[i] & 2) {
dp[i][2] = max(dp[i - 1][2], dp[i][0]) + 1;
}
}
ans += *max_element(dp.back().begin(), dp.back().end());
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 13
Accepted
time: 1ms
memory: 3480kb
input:
1 1 G
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
1 2 RG
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
2 1 W R
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
3 2 WW RW WR
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
4 4 GRRW GWWR WWWW RGRG
output:
0
result:
ok single line: '0'
Test #6:
score: -13
Wrong Answer
time: 0ms
memory: 3424kb
input:
4 4 RGRR RRRG GRGW RGWW
output:
3
result:
wrong answer 1st lines differ - expected: '2', found: '3'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%