QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#923345 | #601. 李超树 | hunction# | Compile Error | / | / | C++14 | 2.8kb | 2025-03-01 20:25:03 | 2025-03-01 20:25:03 |
Judging History
This is the latest submission verdict.
- [2025-03-01 20:25:03]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-03-01 20:25:03]
- Submitted
answer
#include <bits/stdc++.h>
using lld = long long;
const int N = 8e5 + 5;
const lld INF = 0x3f3f3f3f3f3f3f3f;
int n, Q, lsh[N], plsh;
struct SEG {
lld l, r, k, b;
} seg[N];
struct Seg {
lld k, b;
lld operator()(lld x) const { return k * lsh[x] + b; }
} sg[N << 2];
#define mid ((l + r) >> 1)
#define ls (v << 1)
#define rs (v << 1 | 1)
void build(int v = 1, int l = 1, int r = plsh) {
sg[v] = { 0, INF };
if (l == r) return;
build(ls, l, mid);
build(rs, mid + 1, r);
}
void mdf(int L, int U, Seg s, int v = 1, int l = 1, int r = plsh) {
if (r < L || l > U) return;
if (l >= L && r <= U) {
if (s(mid) < sg[v](mid)) std::swap(s, sg[v]);
// if (l == r) return;
if (s(l) <= sg[v](l)) mdf(L, U, s, ls, l, mid);
if (s(r) <= sg[v](r)) mdf(L, U, s, rs, mid + 1, r);
return;
}
mdf(L, U, s, ls, l, mid);
mdf(L, U, s, rs, mid + 1, r);
}
lld qry(int p, int v = 1, int l = 1, int r = plsh) {
if (r < p || l > p) return INF;
if (l == r) return sg[v](p);
return std::min({ qry(p, ls, l, mid), qry(p, rs, mid + 1, r), sg[v](p) });
}
int main() {
scanf("%d%d", &n, &Q);
for (int i = 1; i <= n; i++) {
int a, b, l, r;
scanf("%d%d%d%d", &l, &r, &a, &b);
lsh[++plsh] = l, lsh[++plsh] = --r;
}
for (int i = 1; i <= Q; i++) {
int o;
scanf("%d", &o);
if (o == 1) {
int p;
scanf("%d", &p);
lsh[++plsh] = p;
} else {
int l, r, a, b;
scanf("%d%d%d%d", &l, &r, &a, &b);
lsh[++plsh] = l, lsh[++plsh] = --r;
}
}
// assert(plsh <= 800000);
std::sort(lsh + 1, lsh + plsh + 1);
plsh = std::unique(lsh + 1, lsh + plsh + 1) - lsh - 1;
fseek(stdin, 0, SEEK_SET);
build();
scanf("%d%d", &n, &Q);
for (int i = 1; i <= n; i++) {
int a, b, l, r;
scanf("%d%d%d%d", &l, &r, &a, &b);
seg[i] = { l, r, a, b };
l = std::lower_bound(lsh + 1, lsh + plsh + 1, l) - lsh;
r = std::lower_bound(lsh + 1, lsh + plsh + 1, r - 1) - lsh;
mdf(l, r, { a, b });
}
for (int i = 1; i <= Q; i++) {
int o;
scanf("%d", &o);
if (o == 1) {
int p;
scanf("%d", &p);
// lld ans = INF;
// for (int j = 1; j <= n; j++)
// if (p >= seg[j].l && p < seg[j].r) {
// ans = std::min(ans, seg[j].k * p + seg[j].b);
// // printf("%lld * %d + %lld = %lld\n", seg[j].k, p, seg[j].b, (Seg){ seg[j].k, seg[j].b }(p));
// }
// printf("ans = %lld\n", ans);
p = std::lower_bound(lsh + 1, lsh + plsh + 1, p) - lsh;
lld w = qry(p);
if (w >= INF) puts("NO")//, assert(ans >= INF);
else printf("%lld\n", w)//, assert(ans == w);
} else {
int l, r, a, b;
scanf("%d%d%d%d", &l, &r, &a, &b);
seg[++n] = { l, r, a, b };
l = std::lower_bound(lsh + 1, lsh + plsh + 1, l) - lsh;
r = std::lower_bound(lsh + 1, lsh + plsh + 1, r - 1) - lsh;
mdf(l, r, { a, b });
}
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:89:49: error: expected ‘;’ before ‘else’ 89 | if (w >= INF) puts("NO")//, assert(ans >= INF); | ^ | ; 90 | else printf("%lld\n", w)//, assert(ans == w); | ~~~~ answer.code:40:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | scanf("%d%d", &n, &Q); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:43:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d%d%d%d", &l, &r, &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:48:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%d", &o); | ~~~~~^~~~~~~~~~ answer.code:51:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 51 | scanf("%d", &p); | ~~~~~^~~~~~~~~~ answer.code:55:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 55 | scanf("%d%d%d%d", &l, &r, &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:64:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 64 | scanf("%d%d", &n, &Q); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:67:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 67 | scanf("%d%d%d%d", &l, &r, &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:75:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 75 | scanf("%d", &o); | ~~~~~^~~~~~~~~~ answer.code:78:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 78 | scanf("%d", &p); | ~~~~~^~~~~~~~~~ answer.code:93:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 93 | scanf("%d%d%d%d", &l, &r, &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~