QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#569686 | #1147. Wall | iframe# | 0 | 170ms | 11580kb | C++17 | 2.1kb | 2024-09-17 07:46:27 | 2024-09-17 07:46:27 |
Judging History
answer
#include <iostream>
#include "wall.h"
struct range{
int min, max, active;
void pushup(int h){
if(h > min) min = h;
if(h > max) max = h;
}
void pushdown(int h){
if(h < min) min = h;
if(h < max) max = h;
}
void constrain(range r){
pushup(r.min);
pushdown(r.max);
}
};
const int bsz = 128;
range a[100000];
range b[200];
void push(int i){
if(b[i].active){
for(int j=0; j<bsz; ++j) a[j+i*bsz].constrain(b[i]);
b[i].active = 0;
}
}
void set_min(int h, int l, int r){
//std::cout << "pushup " << h << " (" << l << ' ' << r << ")\n";
if(l/bsz == r/bsz){
push(l/bsz);
for(int i=l; i<=r; ++i) a[i].pushup(h);
b[l/bsz].pushup(h);
}else{
push(l/bsz), push(r/bsz);
for(int i=l; i/bsz==l/bsz; ++i) a[i].pushup(h);
for(int i=l/bsz; i<=r/bsz; ++i) b[i].pushup(h);
for(int i=1+(l/bsz); i<r/bsz; ++i) b[i].active = 1;
for(int i=r; i/bsz==r/bsz; --i) a[i].pushup(h);
}
}
void set_max(int h, int l, int r){
//std::cout << "pushdown " << h << " (" << l << ' ' << r << ")\n";
if(l/bsz == r/bsz){
push(l/bsz);
for(int i=l; i<=r; ++i) a[i].pushdown(h);
b[l/bsz].pushdown(h);
}else{
push(l/bsz), push(r/bsz);
for(int i=l; i/bsz==l/bsz; ++i) a[i].pushdown(h);
for(int i=l/bsz; i<=r/bsz; ++i) b[i].pushdown(h);
for(int i=1+(l/bsz); i<r/bsz; ++i) b[i].active = 1;
for(int i=r; i/bsz==r/bsz; --i) a[i].pushdown(h);
}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for(int i=0; i<k; ++i){
if(op[i]&1){
set_min(height[i], left[i], right[i]);
}else{
set_max(height[i], left[i], right[i]);
}
//for(int i=0; i<n; ++i) std::cout << '[' << a[i].min << ']' << " \n"[i==n-1];
//for(int i=0; i*bsz<n; ++i) std::cout << " [" << b[i].active << ' ' << b[i].min << "] " << " \n"[i==4];
//std::cout << '\n';
}
for(int i=0; i*bsz<n; ++i) push(i);
//for(int i=0; i<n; ++i) std::cout << '[' << a[i].min << ']' << " \n"[i==n-1];
//for(int i=0; i*bsz<n; ++i) std::cout << " [" << b[i].active << ' ' << b[i].min << "] " << " \n"[i==4];
//std::cout << '\n';
for(int i=0; i<n; ++i) finalHeight[i] = a[i].min;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 0ms
memory: 3864kb
input:
1 1 1 0 0 79348
output:
79348
result:
ok single line: '79348'
Test #2:
score: 8
Accepted
time: 1ms
memory: 3932kb
input:
1 5000 2 0 0 91858 1 0 0 85391 2 0 0 5015 1 0 0 41611 1 0 0 42982 1 0 0 70801 1 0 0 14431 2 0 0 14050 2 0 0 70240 2 0 0 84517 1 0 0 42618 1 0 0 92678 1 0 0 63376 1 0 0 36582 2 0 0 39214 2 0 0 22581 2 0 0 10970 1 0 0 67580 2 0 0 44016 2 0 0 12053 1 0 0 42450 1 0 0 12995 2 0 0 71888 2 0 0 29992 2 0 0 ...
output:
18711
result:
ok single line: '18711'
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 3900kb
input:
267 1952 1 30 144 71757 1 170 257 86481 2 112 115 42915 2 11 144 6908 1 141 161 3819 1 91 126 47581 1 107 149 6466 2 81 204 50010 1 9 103 77557 2 115 202 42541 2 199 230 18052 2 98 230 553 1 125 235 36745 2 59 114 71005 1 18 65 78224 2 24 52 21249 1 16 84 47198 1 131 207 81016 2 162 263 21662 1 8 24...
output:
58284 58284 60534 58284 83411 83411 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 34807 ...
result:
wrong answer 228th lines differ - expected: '41076', found: '41034'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 24
Accepted
time: 0ms
memory: 3864kb
input:
1 1 1 0 0 51569
output:
51569
result:
ok single line: '51569'
Test #8:
score: 24
Accepted
time: 73ms
memory: 11580kb
input:
1 500000 1 0 0 92201 1 0 0 88187 1 0 0 78173 1 0 0 57498 1 0 0 95946 1 0 0 72895 1 0 0 46122 1 0 0 67752 1 0 0 45557 1 0 0 46888 1 0 0 84250 1 0 0 24947 1 0 0 30575 1 0 0 54171 1 0 0 80874 1 0 0 81939 1 0 0 88805 1 0 0 71685 1 0 0 28774 1 0 0 33813 1 0 0 41164 1 0 0 78447 1 0 0 85126 1 0 0 30919 1 0...
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Wrong Answer
time: 170ms
memory: 7284kb
input:
18190 207265 1 1435 13396 14900 1 6250 8319 35530 1 7963 12194 50416 1 8286 12081 65629 1 11253 17172 87794 1 9886 16510 63411 1 2728 11446 61035 1 14426 17678 41533 1 2545 7233 6656 1 2158 8796 66853 1 10860 14353 55751 1 4751 14591 72745 1 6971 7654 82848 1 5292 15990 14033 1 10090 16771 27152 1 4...
output:
15148 15148 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 840 ...
result:
wrong answer 129th lines differ - expected: '840', found: '56'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%