QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#487338#2672. RectanglesDan4Life23 904ms842692kbC++232.4kb2024-07-22 20:15:402024-07-22 20:15:41

Judging History

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

  • [2024-07-22 20:15:41]
  • 评测
  • 测评结果:23
  • 用时:904ms
  • 内存:842692kb
  • [2024-07-22 20:15:40]
  • 提交

answer

#include "rect.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)

using ll = long long;
using vi = vector<int>;

const int mxN = 2502;
int n, m;
int pref[mxN][mxN], fen[mxN][mxN];
vector<int> row[mxN][mxN], col[mxN][mxN];
set<pair<int,int>> found[mxN][mxN];

struct Fenwick{
	int fen[mxN];
	void upd(int x, int v){
		for(++x; x<mxN; x+=x&-x) fen[x]+=v;
	}
	int sum(int x){
		int s = 0;
		for(++x; x>0; x-=x&-x) s+=fen[x];
		return s;
	}
	int sum(int l, int r){
		if(l>r)return 0;
		return sum(r)-sum(l-1);
	}
} fenc[mxN], fenr[mxN];

ll count_rectangles(vector<vi> a) {
	n = sz(a); m = sz(a[0]);
	ll ans = 0;
	for(int i = 0; i < n; i++){
		stack<int> S = stack<int>();
		for(int j = m-1; j >= 0; j--){
			while(sz(S) and a[i][S.top()]<a[i][j]) S.pop();
			if(sz(S) and abs(S.top()-j)>1){
				row[i][j].pb(S.top());
			}
			S.push(j);
		}
		S = stack<int>();
		for(int j = 0; j < m; j++){
			while(sz(S) and a[i][S.top()]<a[i][j]) S.pop();
			if(sz(S) and abs(S.top()-j)>1){
				if(a[i][S.top()]!=a[i][j]) 
					row[i][S.top()].pb(j);
			}
			S.push(j);
		}
	}
	for(int j = 0; j < m; j++){
		stack<int> S = stack<int>();
		for(int i = n-1; i >= 0; i--){
			while(sz(S) and a[S.top()][j]<a[i][j]) S.pop();
			if(sz(S) and abs(S.top()-i)>1){
				col[i][j].pb(S.top());
			}
			S.push(i);
		}
		S = stack<int>();
		for(int i = 0; i < n; i++){
			while(sz(S) and a[S.top()][j]<a[i][j]) S.pop();
			if(sz(S) and abs(S.top()-i)>1){
				if(a[S.top()][j]!=a[i][j])
					col[S.top()][j].pb(i);
			}
			S.push(i);
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			sort(all(row[i][j])),sort(all(col[i][j]));
			if(!sz(row[i][j])) continue;
		}
	}
	for(int i = 1; i < n-1; i++){
		for(int j = 0; j < m; j++)
			for(auto u : col[i-1][j]) fenc[u].upd(j,1);
		for(int j = 0; j < m; j++){
			int k = i;
			
			for(auto k : row[i][j]){
				int R = i+1;
				if(i>1 and binary_search(all(row[i-1][j]),k)){
					R = found[i-1][j].lower_bound({k,-1})->second;
				}
				else{
					while(R<n and binary_search(all(row[R][j]),k)) R++;
					found[i][j].insert({k,R});
				}
				//we have fixed col j... k and upper_row i
			    
			    for(auto l : col[i-1][j+1]){
					if(fenc[l].sum(j+1,k-1)!=k-j-1) continue;
					if(l>R) break; ans++;
				}
			}
			for(auto u : col[i-1][j]) fenc[u].upd(j,-1);
		}
	}
	return ans;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 48ms
memory: 301068kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
30 30
3996 3689 3664 3657 3646 3630 3621 3619 3609 3604 3601 3598 3584 3581 3574 3561 3554 3543 3537 3531 3522 3519 3505 3500 3498 3492 3476 3467 3460 3994
3993 3458 3451 3440 3431 3420 3395 3346 3333 3282 3268 3261 3241 3204 3168 3121 3103 3083 3076 2923 2872 28...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
56

result:

wrong answer 3rd lines differ - expected: '784', found: '56'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 10
Accepted

Test #53:

score: 10
Accepted
time: 45ms
memory: 301356kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
3999533 3994407 3992243 3991052 3990430 3988819 3987546 3985557 3983808 3983398 3982565 3981632 3981437 3979888 3979428 3978697 3978033 3975044 3973166 3972565 3971499 3970538 3969576 3969014 3968513 3968337 3966950 3965168 3964140 3963957 3962080 3961829 ...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
2498

result:

ok 3 lines

Test #54:

score: 10
Accepted
time: 52ms
memory: 301580kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2123
3999178 3994918 3993586 3990671 3989261 3988091 3985537 3984649 3983635 3982639 3981319 3980647 3979462 3978557 3977387 3976784 3975890 3975694 3975367 3975193 3973331 3971593 3970332 3969892 3968052 3967213 3966031 3963229 3963001 3962625 3961725 3959892 ...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
2121

result:

ok 3 lines

Test #55:

score: 10
Accepted
time: 60ms
memory: 298804kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #56:

score: 10
Accepted
time: 43ms
memory: 300708kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 1
2
0
3

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #57:

score: 10
Accepted
time: 48ms
memory: 301240kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
3073920 3547280 2578996 515881 1457637 3747191 3335718 1093356 188596 2501359 1707005 923685 1254329 1274578 2451887 1948214 3495100 706306 2036295 3924470 2870740 2253399 2559834 2223853 3524040 448754 2838433 2573451 1627516 2712253 1015735 1941089 29861...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
688

result:

ok 3 lines

Test #58:

score: 10
Accepted
time: 39ms
memory: 303360kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
956507 3801894 3199483 6585310 812126 2818592 2669408 5464237 4252596 1952833 4693677 3365605 4499904 3386900 1960432 4511461 1338880 1430060 3156994 1847807 4802896 5992027 1936374 4766951 4759230 1548846 5592000 759863 3462998 1783861 3893700 6928854 230...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
673

result:

ok 3 lines

Test #59:

score: 10
Accepted
time: 48ms
memory: 301596kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
3899265 2127060 3179336 385518 1777334 2221597 3486817 3371389 1125733 5183809 1203885 1131986 4091262 2101525 4748156 5376347 3256434 4789253 5407807 4461288 2494895 5504801 1781825 190092 1642923 521237 3800202 3385087 3828441 866970 3681590 2845515 1332...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
629

result:

ok 3 lines

Test #60:

score: 10
Accepted
time: 42ms
memory: 301196kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
6827 6690 2935 1032 6925 397 4509 8004 5927 6743 4358 7902 7239 2939 3693 2834 6940 9870 6120 3250 4561 8813 6907 7907 8918 3466 1111 8172 6164 9779 9145 3560 3853 374 8950 6716 4712 8587 6446 1731 9977 8936 5617 8149 4600 4532 5069 3980 9322 4496 6908 962...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
608

result:

ok 3 lines

Test #61:

score: 10
Accepted
time: 39ms
memory: 301284kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
2237965 687445 2621922 3980698 3999973 3999983 2453251 2559651 3489050 2633538 3497108 1214996 2020667 2462216 3555293 2124809 3999991 1864244 19304 1786392 1858083 3169698 3261730 2667102 224139 3999993 240880 1399521 3999964 1558547 1172796 912200 133841...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
569

result:

ok 3 lines

Test #62:

score: 10
Accepted
time: 35ms
memory: 299052kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
1 2500
3699216 130643 5033835 3805008 5074061 2048959 419051 5514783 5194748 2315570 3718514 1399587 4434175 444483 4700750 6507677 5711722 5828756 6567765 1582528 448735 810518 2747305 1045101 5026202 6216297 5563213 242266 6659948 1973694 4883635 756283 3822988...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #63:

score: 10
Accepted
time: 48ms
memory: 298992kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
2 2500
780862 477136 161842 568524 652912 264613 415417 59634 436067 1067956 882087 158951 80968 69382 754204 150303 548432 610319 731231 84272 583452 143105 699314 491045 617561 970063 670786 557308 134628 865642 331432 233825 742850 81239 198370 575889 302003 7...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Subtask #6:

score: 13
Accepted

Test #64:

score: 13
Accepted
time: 34ms
memory: 300720kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
10 10
1 1 0 0 1 0 0 1 0 0
0 1 0 0 1 0 0 1 1 0
0 1 0 0 0 0 0 1 1 0
1 0 0 0 1 0 0 0 1 1
1 0 1 1 0 0 1 1 0 1
0 0 1 0 0 0 1 1 0 0
1 0 1 1 1 1 1 1 1 0
1 0 0 0 1 1 1 1 0 0
1 0 0 1 1 0 1 0 1 1
0 0 0 0 0 1 0 1 1 0

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
2

result:

ok 3 lines

Test #65:

score: 13
Accepted
time: 408ms
memory: 559952kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
1234 2321
0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 1 1...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
116238

result:

ok 3 lines

Test #66:

score: 13
Accepted
time: 904ms
memory: 838316kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
2487 2500
1 1 0 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 1 0 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1 1 0 1...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
250951

result:

ok 3 lines

Test #67:

score: 13
Accepted
time: 861ms
memory: 842692kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
2500 2499
0 1 1 1 1 0 1 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 1 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 1 1 0 0 0 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
251914

result:

ok 3 lines

Test #68:

score: 13
Accepted
time: 887ms
memory: 841280kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
2500 2500
1 0 1 0 1 0 0 0 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1 0 1 0 1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 1 1 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 0 1 0 1 1 0 1 1 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 0 0 0...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
252270

result:

ok 3 lines

Test #69:

score: 13
Accepted
time: 131ms
memory: 329144kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
1234 2500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #70:

score: 13
Accepted
time: 201ms
memory: 356156kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
2500 2345
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #71:

score: 13
Accepted
time: 199ms
memory: 359892kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
2500 2500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Subtask #7:

score: 0
Skipped

Dependency #1:

0%