QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#521918 | #7047. Pot!! | Blizzard | WA | 2ms | 9840kb | C++23 | 4.0kb | 2024-08-16 16:40:09 | 2024-08-16 16:40:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
//--------------------------------
// #define int long long
#define LL long long
#define lc p << 1
#define rc p << 1 | 1
#define lowbit(x) x & (-x)
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
// #pragma GCC optimize(2)
#define Blizzard ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
inline void read(LL &a)
{
LL s = 0, w = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
s = s * 10 + ch - '0';
ch = getchar();
}
a = s * w;
}
//-----------------------------------------
const int N = 1e5 * 4 + 7;
int n, q;
struct node
{
int l, r;
int num;
int lazy;
} t2[N], t3[N], t5[N], t7[N];
void push_down(int p, node a[])
{
if (a[p].lazy)
{
a[lc].num += a[p].lazy;
a[rc].num += a[p].lazy;
a[lc].lazy = a[p].lazy;
a[rc].lazy = a[p].lazy;
a[p].lazy = 0;
}
return;
}
void pushup(int p, node a[])
{
a[p].num = max(a[lc].num, a[rc].num);
}
int query(int l, int r, int p, node a[])
{
int ans = 0;
if (l <= a[p].l && a[p].r <= r)
{
return a[p].num;
}
int mid = a[p].l + a[p].r >> 1;
push_down(p, a);
if (l <= mid)
ans = max(ans, query(l, r, lc, a));
if (r > mid)
ans = max(ans, query(l, r, rc, a));
return ans;
}
void build(int p, int l, int r, node a[])
{
a[p] = {l, r, 0, 0};
if (l == r)
return;
int mid = l + r >> 1;
build(lc, l, mid, a);
build(rc, mid + 1, r, a);
a[p].num = 0;
}
void add(int p, int l, int r, node a[], int k)
{
if (l <= a[p].l && a[p].r <= r)
{
a[p].lazy += k;
a[p].num += k;
return;
}
int mid = a[p].l + a[p].r >> 1;
push_down(p, a);
if (l <= mid)
add(lc, l, r, a, k);
if (r > mid)
add(rc, l, r, a, k);
pushup(p, a);
}
void sovle()
{
cin >> n >> q;
build(1, 1, n, t2);
build(1, 1, n, t3);
build(1, 1, n, t5);
build(1, 1, n, t7);
while (q--)
{
string s;
int l, r;
cin >> s >> l >> r;
if (s[1] == 'A')
{
int ans1, ans2;
ans1 = max(query(l, r, 1, t2), query(l, r, 1, t3));
ans2 = max(query(l, r, 1, t7), query(l, r, 1, t5));
cout << "ANSWER " << max(ans1, ans2) << endl;
}
else
{
int k;
cin >> k;
switch (k)
{
case 2:
{
add(1, 1, n, t2, 1);
break;
}
case 3:
{
add(1, 1, n, t3, 1);
break;
}
case 4:
{
add(1, 1, n, t2, 2);
break;
}
case 5:
{
add(1, 1, n, t5, 1);
break;
}
case 6:
{
add(1, 1, n, t2, 1);
add(1, 1, n, t3, 1);
break;
}
case 7:
{
add(1, 1, n, t7, 1);
break;
}
case 8:
{
add(1, 1, n, t2, 3);
break;
}
case 9:
{
add(1, 1, n, t3, 3);
break;
}
case 10:
{
add(1, 1, n, t2, 1);
add(1, 1, n, t5, 1);
break;
}
break;
default:
break;
}
}
}
}
signed main()
{
Blizzard;
sovle();
return 0;
}
/*
while (l < r)
{
int mid = l + r >> 1;
if (check(mid)) r = mid;
else l = mid + 1;
}
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 9840kb
input:
5 6 MULTIPLY 3 5 2 MULTIPLY 2 5 3 MAX 1 5 MULTIPLY 1 4 2 MULTIPLY 2 5 5 MAX 3 5
output:
ANSWER 1 ANSWER 2
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 9796kb
input:
100 1000 MULTIPLY 3 13 8 MULTIPLY 35 86 9 MAX 5 92 MAX 30 86 MAX 4 99 MAX 36 66 MULTIPLY 27 41 5 MAX 21 40 MULTIPLY 5 20 10 MAX 7 98 MAX 10 10 MAX 40 44 MAX 27 47 MAX 37 54 MAX 61 72 MULTIPLY 10 13 8 MAX 19 30 MAX 27 96 MULTIPLY 54 94 9 MAX 29 88 MAX 7 45 MULTIPLY 21 96 7 MULTIPLY 77 98 9 MULTIPLY 3...
output:
ANSWER 3 ANSWER 3 ANSWER 3 ANSWER 3 ANSWER 3 ANSWER 4 ANSWER 3 ANSWER 4 ANSWER 4 ANSWER 4 ANSWER 4 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 9 ANSWER 9 ANSWER 9 ANSWER 9 ANSWER 9 ANSWER 9 ANSWER 3 ANSWER 9 ANSWER 9 ANSWER 10 ANSWER 11 ANSWER 11 ANSWER 14 ANSWER 14 ANSWER 5 ANSWER 11 ANSWER 14 ANSWE...
result:
wrong answer 2nd lines differ - expected: 'ANSWER 2', found: 'ANSWER 3'