QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#277185 | #7047. Pot!! | zzuqy# | WA | 0ms | 9708kb | C++20 | 2.2kb | 2023-12-06 16:09:57 | 2023-12-06 16:09:57 |
Judging History
answer
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <queue>
#include <bitset>
using namespace std;
const int N = 1e5 +9 ;
typedef long long ll;
struct SegTree {
struct node {
int l, r, mx, lazy;
} tr[N << 2];
void build(int u, int l, int r) {
tr[u] = {l, r, 0, 0};
if (l == r) {
return;
}
int md = l + r >> 1;
build(u << 1, l, md), build(u << 1 | 1, md + 1, r);
}
void pushdown(int u) {
if (tr[u].lazy) {
tr[u << 1].lazy += tr[u].lazy;
tr[u << 1 | 1].lazy += tr[u].lazy;
tr[u << 1].mx += tr[u].lazy;
tr[u << 1 | 1].mx += tr[u].lazy;
tr[u].lazy = 0;
}
}
void pushup(int u) { tr[u].mx = max(tr[u << 1].mx, tr[u << 1 | 1].mx); }
void modify(int u, int ql, int qr, int k) {
if (ql <= tr[u].l && tr[u].r <= qr) {
tr[u].lazy += k;
tr[u].mx += k;
return;
}
int md = tr[u].l + tr[u].r >> 1;
if (ql <= md)
modify(u << 1, ql, qr, k);
if (md < qr)
modify(u << 1 | 1, ql, qr, k);
pushup(u);
}
int query(int u, int ql, int qr) {
if (ql <= tr[u].l && tr[u].r <= qr) {
return tr[u].mx;
}
pushdown(u);
int md = tr[u].l + tr[u].r >> 1;
int res = 0;
if (ql <= md)
res = query(u << 1, ql, qr);
if (md < qr)
res = max(res, query(u << 1 | 1, ql, qr));
return res;
}
} Sgt[4]; // 2 3 5 7
const int primes[] = {2, 3, 5, 7};
int main() {
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int j = 0; j < 4; ++j)
Sgt[j].build(1, 1, n);
for (int i = 1; i <= m; ++i) {
string op;
int x, y, z;
cin >> op;
if (op[1] == 'U') {
cin >> x >> y >> z;
for (int j = 0; j < 4; ++j) {
int p = primes[j];
while (z % p == 0) {
Sgt[j].modify(1, x, y, 1);
z /= p;
}
}
} else {
cin >> x >> y;
int ans = 0;
for (int j = 0; j < 4; ++j)
ans = max(ans, Sgt[j].query(1, x, y));
cout << "ANSWER " << ans << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9588kb
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: 0ms
memory: 9708kb
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 2 ANSWER 3 ANSWER 2 ANSWER 2 ANSWER 4 ANSWER 4 ANSWER 2 ANSWER 2 ANSWER 2 ANSWER 2 ANSWER 1 ANSWER 2 ANSWER 4 ANSWER 7 ANSWER 4 ANSWER 4 ANSWER 7 ANSWER 6 ANSWER 1 ANSWER 4 ANSWER 2 ANSWER 8 ANSWER 3 ANSWER 4 ANSWER 11 ANSWER 10 ANSWER 10 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ANSWER 7 ...
result:
wrong answer 17th lines differ - expected: 'ANSWER 6', found: 'ANSWER 4'