QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#439234 | #8575. Three Person Tree Game | real_sigma_team# | WA | 7ms | 253488kb | C++23 | 2.3kb | 2024-06-11 18:15:00 | 2024-06-11 18:15:00 |
Judging History
answer
//#pragma GCC optimize("O3,unroll-loops,inline")
#include <bits/stdc++.h>
using namespace std;
vector<string> note = {"do", "re", "mi", "fa", "so", "la", "ti"};
struct node {
int dp[8][8];
node() {
for (auto &i: dp)
for (int &j: i)
j = -1000000;
}
node(char ch) {
for (auto &i: dp)
for (int &j: i)
j = -1000000;
dp[7][7] = 0;
for (int i = 0; i < 7; ++i) {
if (ch == note[i][1])
dp[i][7] = 0;
if (ch == note[i][0])
dp[7][i] = 0;
}
}
};
node operator+(node a, node b) {
node c;
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 8; ++j) {
c.dp[i][j] = max(c.dp[i][j], a.dp[i][j]);
c.dp[i][j] = max(c.dp[i][j], b.dp[i][j]);
}
for (int k = 0; k < 8; ++k)
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 8; ++j)
c.dp[i][j] = max(c.dp[i][j], a.dp[i][k] + b.dp[k][j] + 2 * (k < 7));
return c;
}
const int N = 5e5;
node tr[2 * N];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, q;
cin >> n >> q;
string s;
cin >> s;
for (int i = 0; i < n; ++i) {
tr[i + n] = node(s[i]);
}
for (int i = n - 1; i; --i) tr[i] = tr[i << 1] + tr[i << 1 | 1];
while (q--) {
char t;
cin >> t;
if (t == '?') {
int l, r;
cin >> l >> r;
int len = r - l + 1;
--l, --r;
node left, right;
for (l += n, r += n; l <= r; l >>= 1, r >>= 1) {
if (l & 1) left = left + tr[l++];
if (~r & 1) right = tr[r--] + right;
}
node res = left + right;
int ans = 0;
for (auto &i: res.dp)
for (int j: i)
ans = max(ans, j);
cout << len - ans << '\n';
} else {
int l, r;
cin >> l >> r;
--l, --r;
string ns;
cin >> ns;
for (int i = l; i <= r; ++i) {
tr[i + n] = node(ns[i - l]);
for (int j = i + n; j > 1; j >>= 1, tr[j] = tr[j << 1] + tr[j << 1 | 1]);
}
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 253488kb
input:
2 3 1 2 3 2 1 3 1 4 1 2 3 1 4 2 4 3 4
output:
result:
wrong answer 1st lines differ - expected: 'A', found: ''