| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1327652 | gs12117 | Pyramid Base (IOI08_pyramid_base) | C++17 | 576 ms | 67764 KiB |
#include<cstdio>
#include<algorithm>
int m, n, b, p;
int pyr[401000][5];
struct st {
int x, yl, yr;
int val;
bool operator<(const st& r)const {
return x < r.x;
}
};
st sl[801000];
const int itsz = 1 << 20;
int logitsz = 20;
struct itnode {
int cover;
int len;
int lemp, remp, iemp;
bool havecover;
itnode operator+(const itnode& r)const {
itnode res;
res.cover = 0;
res.len = len + r.len;
res.lemp = lemp;
res.remp = r.remp;
if (!havecover) {
res.lemp = len + r.lemp;
}
if (!r.havecover) {
res.remp = r.len + remp;
}
res.havecover = (havecover || r.havecover);
res.iemp = remp + r.lemp;
if (res.iemp < iemp)res.iemp = iemp;
if (res.iemp < r.iemp)res.iemp = r.iemp;
return res;
}
};
itnode it[2 * itsz];
itnode basenode() {
itnode res;
res.len = 1;
res.cover = 0;
res.havecover = false;
res.lemp = res.len;
res.remp = res.len;
res.iemp = res.len;
return res;
}
itnode nonode() {
itnode res;
res.len = 0;
res.cover = 0;
res.havecover = false;
res.lemp = res.len;
res.remp = res.len;
res.iemp = res.len;
return res;
}
void addcover(int x, int v) {
it[x].cover += v;
if (it[x].cover > 0) {
it[x].lemp = 0;
it[x].remp = 0;
it[x].iemp = 0;
it[x].havecover = true;
}
else {
if (x >= itsz) {
it[x].havecover = false;
it[x].lemp = it[x].len;
it[x].remp = it[x].len;
it[x].iemp = it[x].len;
}
else {
it[x] = it[x * 2] + it[x * 2 + 1];
}
}
}
void upcover(int x) {
if (x >= itsz)return;
if (it[x].cover <= 0) {
it[x] = it[x * 2] + it[x * 2 + 1];
}
}
void itinit(int len) {
for (int i = 1; i <= len; i++) {
it[itsz + i] = basenode();
}
int s = itsz + 1;
int e = itsz + len;
s /= 2;
e /= 2;
while (s > 0) {
for (int i = s; i <= e; i++) {
it[i] = it[i * 2] + it[i * 2 + 1];
}
s /= 2;
e /= 2;
}
}
void itpush(int start, int end, int val) {
start += itsz;
end += itsz;
int ps = start;
int pe = end;
while (start <= end) {
if (start % 2 == 1) {
addcover(start, val);
start++;
}
if (end % 2 == 0) {
addcover(end, val);
end--;
}
start /= 2;
end /= 2;
}
for (int i = 1; i <= logitsz; i++) {
upcover(ps >> i);
if ((pe >> i) != (ps >> i))upcover(pe >> i);
}
}
int itcalc() {
return it[1].iemp;
}
int main() {
scanf("%d%d%d%d", &m, &n, &b, &p);
for (int i = 0; i < p; i++) {
scanf("%d%d%d%d%d", &pyr[i][0], &pyr[i][1], &pyr[i][2], &pyr[i][3], &pyr[i][4]);
sl[i * 2].x = pyr[i][0];
sl[i * 2].yl = pyr[i][1];
sl[i * 2].yr = pyr[i][3];
sl[i * 2].val = 1;
sl[i * 2 + 1].x = pyr[i][2];
sl[i * 2 + 1].yl = pyr[i][1];
sl[i * 2 + 1].yr = pyr[i][3];
sl[i * 2 + 1].val = -1;
}
std::sort(sl, sl + 2 * p);
sl[2 * p].x = 2 * (m + n) + 1000;
int xl = 0;
int xr = 0;
int pl = 0;
int pr = 0;
itinit(n);
int ans = 0;
while (xr <= m) {
int xd = xr - xl;
int yd = itcalc();
if (yd < xd) {
if (ans < yd)ans = yd;
xl++;
while (sl[pl].x <= xl) {
if (sl[pl].val < 0)itpush(sl[pl].yl, sl[pl].yr, sl[pl].val);
pl++;
}
}
else {
if (ans < xd)ans = xd;
xr++;
while (sl[pr].x <= xr) {
if (sl[pr].val > 0)itpush(sl[pr].yl, sl[pr].yr, sl[pr].val);
pr++;
}
}
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
