QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#461320#4563. Radio Towersq258233q0 1ms3940kbC++141.9kb2024-07-02 17:55:572024-07-02 17:55:58

Judging History

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

  • [2024-07-02 17:55:58]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3940kb
  • [2024-07-02 17:55:57]
  • 提交

answer

#include "towers.h"

#include <vector>
#include<bits/stdc++.h>

namespace Sol{

using namespace std;
using ll=long long;
using u64=unsigned long long;
//using lll=__int128_t;
using lf=long double;
using Pr=pair<int,int>;
#define F(i,l,r) for(ll i=l;i<=ll(r);++i)
#define G(i,r,l) for(ll i=r;i>=ll(l);--i)
#define ct const
#define il inline
#define pb push_back
#define fi first
#define se second
#define mkr make_pair
template<class T>
il void tomn(T&x,T ct&y){y<x?x=y,0:0;}
template<class T>
il void tomx(T&x,T ct&y){x<y?x=y,0:0;}
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define CUT dbg("===================\n")
ct lf EPS=1e-10L;
il int dcmp(lf x){return fabs(x)<=EPS?0:(x<0?-1:1);}
//ct ll INF=4e18L;
ct int INF=1.02e9;
//il void rd(int&x){scanf("%d",&x);}
//il void rd(ll&x){scanf("%lld",&x);}

ct ll P=1000000007;
void add2(ll&x,ll y){x+=y,x-=((-(x>=P))&P);}
void sub2(ll&x,ll y){x-=y,x+=((-(x<0))&P);}
ll add(ll x,ll y){return add2(x,y),x;}
ll sub(ll x,ll y){return sub2(x,y),x;}

ct int N=1.02e5;
int n,h[N],l[N],r[N];
struct D{int x,i;};
struct Seg{int l,r;};
int qry(int s,int t,int d){
	static D st[N];
	int top;
	top=0,st[++top]=D{INF,0};
	F(i,1,n){
		for(;st[top].x<h[i];--top);
		st[++top]=D{h[i],(int)i};
		l[i]=(lower_bound(st,st+top+1,h[i]+d,[&](D d,int x){
			return d.x>=x;
		})-1)->i;
	}
	top=0,st[++top]=D{INF,n+1};
	G(i,n,1){
		for(;st[top].x<h[i];--top);
		st[++top]=D{h[i],(int)i};
		r[i]=(lower_bound(st,st+top+1,h[i]+d,[&](D d,int x){
			return d.x>=x;
		})-1)->i;
	}
	vector<Seg>vec;
	F(i,s,t)vec.pb(Seg{l[i],r[i]});
	sort(vec.begin(),vec.end(),[&](Seg x,Seg y){
		return x.r<y.r;
	});
	int lst=-INF,ans=0;
	for(Seg x:vec)if(x.l>=lst)
		++ans,lst=x.r;
	return ans;
}

}

void init(int N, std::vector<int> H) {
	using namespace Sol;
	n=N;
	F(i,1,n)h[i]=H[i-1];
}

int max_towers(int L, int R, int D) {
	return Sol::qry(L+1,R+1,D);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

59640
49885 57346 58504 87383 113182 129676 204090 205404 259925 276583 300332 324014 333675 359377 364049 408489 414852 428310 438038 440113 458193 554789 643468 666525 683112 690791 707313 720088 741028 748785 789826 796576 800966 832867 851750 861044 862283 900756 926925 939560 955678 965636 9740...

output:

1
4875
1
1
44706
27054
3169
1
5782
1
11898
2002
9227
1
12054
2128
8266
10443
4441
1
1
12936
20032
10110
13270
408
25809
15045
10367
3689
32842
18437
16708
8661
1
27266
2592
1
1
11189
25060
19427
4484
20185
21968
23050
6082
17487
17638
15674
10657
27583
15671
1
986
26946
1
14427
1
30279
1
1
1
1
21743...

result:


Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 1ms
memory: 3940kb

input:

425
753881706 405729786 890889563 29736246 598281970 208352067 357783003 663497023 178397034 4832890 562140755 510307001 354540290 538848551 436879256 86659033 42928516 24145404 749159097 118423198 506851985 204895765 719719998 726244368 991372008 681703480 799303017 657138050 88278945 417801236 260...

output:

14

result:

wrong answer 3rd lines differ - expected: '13', found: '14'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Time Limit Exceeded

Test #65:

score: 0
Time Limit Exceeded

input:

99308
491693640 24020487 317364185 726230755 737284540 951143270 709116045 641023337 360629062 964879440 47884022 532494780 803629825 635450854 688041998 573937055 113198481 191311841 929603572 636688 598629732 895342035 396521271 619919754 716589045 657789547 373121546 866402108 609316614 60046511 ...

output:

11903
4770
14278
13956
571
9308
4389
9
22097
16784
26037
2813
8487
16602
2029
6158
17236
29707
19863
12083
20816
18090
4195
11612
4623
6658
7660
624
9839
13012
14475
11799
14795
6365
7308
5981
13614
14208
15922
17325
6020
10291
1819
29076
3117
6638
5810
28747
14944
9541
5498
1015
5001
20938
305
1993...

result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #86:

score: 0
Time Limit Exceeded

input:

23881
605288257 422163932 155875880 339929874 76049859 196344969 958160745 767945284 469191956 997116006 387749577 15911341 920437918 367576975 800789357 351557615 283723284 369507452 841548133 643412903 309731505 256549694 370065644 699518122 559017597 347646657 469353381 575240521 501893001 454519...

output:

9327
9529
23087
13232
12906
9026
19797
10286
19332
11655
13503
8682
14051
17802
12642
10761
8269
9234
7964
17821
10969
9547
9104
13748
22462
19269
12073
19413
11111
13473
13354
13288
17007
21832
11778
17276
8154
9692
19467
11727
9316
13741
20836
10539
17358
21594
10452
9610
9232
11372
13005
10484
18...

result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #97:

score: 0
Time Limit Exceeded

input:

88768
238644804 620122421 789364401 899010695 885388612 437964772 845379533 657562749 773925456 625793781 916240972 291506550 379611161 905077982 629848170 530056471 520438258 806293637 326792996 785404568 74285074 565304193 846963319 63529729 804909008 212070492 69936548 656129389 408708069 3070450...

output:

9942
25449
6605
25879
31994
2740
28430
12433
28909
21368
160
15902
11548
26103
12871
12373
7376
27341
2336
5478
30854
8168
24260
17600
7753
16816
29388
21465
919
7296
23137
10470
8362
2373
8442
843
1039
4187
11945
15699
9901
3660
21519
3093
2714
13164
32676
6348
12133
6802
3220
27449
11373
19738
223...

result:


Subtask #7:

score: 0
Skipped

Dependency #1:

0%