QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569687#1147. Walliframe#0 265ms11776kbC++172.1kb2024-09-17 07:48:092024-09-17 07:48:09

Judging History

你现在查看的是最新测评结果

  • [2024-09-17 07:48:09]
  • 评测
  • 测评结果:0
  • 用时:265ms
  • 内存:11776kb
  • [2024-09-17 07:48:09]
  • 提交

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 = 256;

range a[100000];
range b[512];

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: 3912kb

input:

1 1
1 0 0 79348

output:

79348

result:

ok single line: '79348'

Test #2:

score: 8
Accepted
time: 1ms
memory: 3980kb

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: 8
Accepted
time: 0ms
memory: 3940kb

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:

ok 267 lines

Test #4:

score: 0
Wrong Answer
time: 6ms
memory: 4004kb

input:

10000 5000
1 2237 2818 16629
2 3559 7378 25221
2 5353 6596 18247
2 7 8525 7339
2 7753 9730 78256
2 6301 8598 74433
1 5372 6260 23526
2 8231 9732 89822
2 1050 6451 41238
1 6362 6459 90393
2 1812 4993 90638
2 3518 4329 88017
2 412 6273 45512
1 6297 8927 87237
2 763 8022 2387
1 8561 8995 32427
2 1364 3...

output:

0
0
8060
8060
8060
8060
8060
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
96327
9...

result:

wrong answer 257th lines differ - expected: '31610', found: '67899'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 24
Accepted
time: 0ms
memory: 3892kb

input:

1 1
1 0 0 51569

output:

51569

result:

ok single line: '51569'

Test #8:

score: 24
Accepted
time: 69ms
memory: 11776kb

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: 265ms
memory: 7440kb

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 4097th lines differ - expected: '56', found: '18'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%