QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#630711#4096. 코딩 테스트Matutino0 853ms33092kbC++172.6kb2024-10-11 20:06:252024-10-11 20:06:27

Judging History

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

  • [2024-10-11 20:06:27]
  • 评测
  • 测评结果:0
  • 用时:853ms
  • 内存:33092kb
  • [2024-10-11 20:06:25]
  • 提交

answer

#include<bits/stdc++.h>
#define reg register
#define int long long
inline int min(reg int x,reg int y){return x<y?x:y;}
inline bool cmin(reg int &x,reg int y){return x>y?x=y,1:0;}
const int N=5e5+10,INF=1e18;
int n,m,a[N],b[N],idx,rt[N],lim[N];
struct Line{
	int k,b;
	inline int operator()(const int &A)const{return k*A+b;}
	inline Line operator+(const Line &A)const{return {k+A.k,b+A.b};}
}tmp,tmp2;
struct Node{Line pre,suf,sum,mn; int t;}tr[N<<2];
int ls[N<<5],rs[N<<5];
inline int upd(reg Line &A,reg Line B,reg int x){
	if (A(x)>B(x)) std::swap(A,B);
	return A.k<=B.k?INF:(B(x)-A(x))/(A.k-B.k)+x+1; 
}
inline Node merge(reg Node A,reg Node B,reg int x){
	reg Node C={A.pre,B.suf,A.sum+B.sum,A.mn,min(A.t,B.t)};
	cmin(C.t,upd(C.suf,B.sum+A.suf,x)),cmin(C.t,upd(C.pre,A.sum+B.pre,x));
	cmin(C.t,upd(C.mn,B.mn,x)),cmin(C.t,upd(C.mn,A.suf+B.pre,x));
	return C;
}
void build(reg int &o,reg int l,reg int r){
	o=++idx; if (l==r) return tmp={-1,a[l]+b[l]},tmp2={-1,a[l]+b[l]+b[l-1]},tr[o]={tmp,tmp2,tmp,tmp2,INF},void();
	reg int mid=l+r>>1; build(ls[o],l,mid),build(rs[o],mid+1,r),tr[o]=merge(tr[ls[o]],tr[rs[o]],0);
}
void modify(reg int &o,reg int pre,reg int l,reg int r,reg int x){
	tr[o=++idx]=tr[pre],ls[o]=ls[pre],rs[o]=rs[pre]; if (l==r) return; reg int mid=l+r>>1;
	if (tr[ls[o]].t==x) modify(ls[o],ls[pre],l,mid,x); if (tr[rs[o]].t==x) modify(rs[o],rs[pre],l,mid,x); 
	tr[o]=merge(tr[ls[o]],tr[rs[o]],x);
}
Node query(reg int o,reg int l,reg int r,reg int L,reg int R,reg int x){
	if (L<=l&&r<=R) return tr[o]; reg int mid=l+r>>1;
	if (R<=mid) return query(ls[o],l,mid,L,R,x); if (L>mid) return query(rs[o],mid+1,r,L,R,x);
	return merge(query(ls[o],l,mid,L,R,x),query(rs[o],mid+1,r,L,R,x),x);
}
#undef int
std::vector<int> testset(std::vector<int> A, std::vector<int> B, std::vector<int> L, std::vector<int> U){
	std::vector<int> res;
	#define int long long
	n=A.size(); for (reg int i=1;i<=n;i++) a[i]=A[i-1],i<n?b[i]=B[i-1]:0;
	build(rt[m=1],1,n),lim[m]=0;
	while (1){
		if (tr[rt[m]].t>1000000000) break;
		lim[m+1]=tr[rt[m]].t,modify(rt[m+1],rt[m],1,n,lim[m+1]),m++;
	}
	// for (reg int i=1;i<=m;i++) std::cerr<<lim[i]<<" "; std::cerr<<"\n";
	// assert(0);
	for (reg int i=0;i<L.size();i++){
		// std::cerr<<"<< "<<i<<"\n";
		reg int l=1,r=m,now,pl=L[i]+1,pr=U[i]+1;
		while (l<=r){
			reg int mid=l+r>>1;
			if (query(rt[mid],1,n,pl,pr,lim[mid]).mn(lim[mid])>=0) l=mid+1,now=mid; else r=mid-1;
		}
		// std::cerr<<"qwq\n";
		reg int ans; l=lim[now],r=lim[now+1]-1;
		while (l<=r){
			reg int mid=l+r>>1;
			if (query(rt[now],1,n,pl,pr,mid).mn(mid)>=0) l=mid+1,ans=mid; else r=mid-1;
		}
		res.push_back(ans);
	}
	return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 16104kb

input:

2 1
746 733
619
0 1

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
0

result:

wrong answer 2nd lines differ - expected: '1049', found: '0'

Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

100000 100
19808256 24285218 35700559 40271678 34848402 69357487 68150704 33167327 11009744 51263605 95965914 99915162 98938894 25021047 41422333 21862896 68096319 74258633 12048507 49456137 34627666 2028097 39447833 88604280 58491153 12515029 84711345 70929241 88589416 4246292 47068575 45272978 203...

output:

Unauthorized output

result:


Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 36
Accepted
time: 853ms
memory: 32324kb

input:

5000 100000
93608251 16211038 93349835 94727166 27749929 28580474 39398397 58978075 32539760 49630110 14330110 62149976 63372420 45530888 44815920 40624609 4942456 35245376 9509556 17318048 91459277 83937735 82541206 16905922 22994630 56339982 33531160 45581398 67402358 51369287 2786263 53237145 830...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
14700204
21288935
6977271
6977271
12647030
6977271
6977271
6977271
12647030
6977271
6977271
6977271
6977271
6977271
6977271
6977271
12647030
12647030
6977271
6977271
12647030
6977271
6977271
6977271
12647030
37448760
6977271
14700204
6977271
12647030
6977271
6977...

result:

ok 100001 lines

Test #32:

score: 36
Accepted
time: 822ms
memory: 32380kb

input:

5000 100000
82828123 95799582 43820359 90127238 56235887 78150460 93507009 96591806 86423481 94895084 82100076 94194957 91441292 90209583 97860572 97698652 68557340 99706593 34044897 93238691 86202199 88683188 86559347 93076047 73141247 97130836 89727854 98129702 85630933 80894303 73045164 85475297 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
126575860
126575860
126575860
143701045
126575860
170613823
143701045
143701045
126575860
126575860
172861749
126575860
126575860
126575860
126575860
126575860
143701045
143519126
126575860
143701045
133698077
126575860
152649240
126575860
152649240
152649240
126...

result:

ok 100001 lines

Test #33:

score: 36
Accepted
time: 696ms
memory: 33092kb

input:

5000 100000
96012616 99429813 99624750 99381014 99980502 99993037 99703586 99988048 99965210 99995994 99025192 84244649 97417197 99892788 99916470 99938573 96446673 99989453 85387315 99888398 99291260 99601349 91417592 99813237 99635623 92171538 96939941 99632513 99336374 98693179 98680317 99927733 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
190737948
191089420
190737948
190737948
190737948
193216637
192474531
198593332
190737948
190737948
190103821
190103821
190737948
190737948
190737948
192474531
191089420
190737948
191089420
190737948
190737948
190737948
190737948
190737948
190737948
190737948
190...

result:

ok 100001 lines

Test #34:

score: 36
Accepted
time: 675ms
memory: 30308kb

input:

5000 100000
99978725 97985760 99891087 99988604 99999807 98436639 99985292 99818187 99802110 99996115 99767504 99998401 99984142 99997383 99810342 99995097 98415433 99501601 99914594 98590782 99683661 99943693 99533008 99859805 99707573 99367915 99474753 99983916 99997167 98891838 99807634 99698506 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
198480881
198291296
198117670
198118365
198291296
198118365
198291296
198118365
198731701
198118365
198118365
198291296
198118365
198118365
198118365
198118365
198118365
198340225
198118365
199319379
198162408
198409770
198118365
198991009
198291296
198291296
198...

result:

ok 100001 lines

Test #35:

score: 36
Accepted
time: 640ms
memory: 31192kb

input:

5000 100000
99986950 99924484 99934484 99717257 99971564 99998421 99978242 99895349 96749877 99997733 99993399 99919842 99998954 99999449 99998116 99933290 99617595 99995807 99998100 99980424 99998867 99918225 99970258 99684050 99998452 99999220 99999506 99996872 99824516 99997016 99683701 99999926 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
199686196
199807313
199639454
199642418
199906533
199638768
199843110
199624132
199632837
199624132
199624132
199663148
199928583
199687670
199624132
200459148
199679834
199922294
199643504
199738578
199505764
199690967
199624132
199671888
199624132
199635012
199...

result:

ok 100001 lines

Test #36:

score: 0
Wrong Answer
time: 610ms
memory: 32424kb

input:

5000 100000
99999716 99999957 99999766 99999362 99994650 99983426 99982710 99992590 99970275 99999417 99923465 99997667 99999313 99969772 99999965 99999765 99999932 99970260 99971602 99998087 99995083 99990390 99999965 99999903 99999983 99987568 99764871 99988931 99999921 99999997 99948237 99997572 ...

output:

e4bc1609-b8fd-4286-b31c-e5e8e5765738
200012937
199928913
199941598
199927017
199943363
200017855
200246008
199948078
199925951
199947905
199928097
199951853
199926393
199951747
200459076
199948116
199964966
199962331
200136933
199925034
200004530
199958929
199926718
200330875
199977900
199928348
199...

result:

wrong answer 9105th lines differ - expected: '299988579', found: '199979215'

Subtask #4:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

100000 100000
8220608 27643636 9653375 7527483 4568995 4937547 27001430 10512886 14865249 54452685 31213146 1223559 25266797 9367382 5798933 1485258 33036920 2988776 5046089 41823731 6136379 20608943 10327625 90179994 75745370 21933251 3376845 19790905 52189711 21570452 18938610 18445540 26257950 24...

output:

Unauthorized output

result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%