QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#312796#5264. Wyprzedzanietuxuanming20240 135ms12120kbC++141.6kb2024-01-24 12:11:022024-01-24 12:11:02

Judging History

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

  • [2024-01-24 12:11:02]
  • 评测
  • 测评结果:0
  • 用时:135ms
  • 内存:12120kb
  • [2024-01-24 12:11:02]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef LOCAL
#include "txm/debug.h"
#endif
using namespace std;
typedef long double ld;
typedef long long ll;
const int N=100005;
const ld eps=1e-6;
int n,D,d[N],x[N],nxt[N],p[N][17],s[N],ans;
ld V,v[N],t[N],pos[N];
bool iseq(ld x,ld y) {return fabs(x-y)<eps;}
ld ask(int a,ld tt)
{
	if(tt<t[a]) return x[a]+v[a]*tt;
	int y=a;
	for(int i=16;i>=0;i--)
		if(p[y][i]&&(tt>t[p[y][i]]||iseq(t[p[y][i]],tt))) y=p[y][i];
	tt-=t[y];
	return pos[y]+v[p[y][0]]*tt-(s[y]-s[a]);
}
signed main()
{
	int w,m;
	scanf("%d %d %d %d",&n,&D,&w,&m),V=(ld)w/m;
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d %d %d",x+i,d+i,&w,&m);
		v[i]=(ld)w/m,s[i]=s[i-1]+d[i];
	}
	nxt[n]=n+1,t[n]=1e14,pos[n]=x[n];
	for(int i=n-1;i>=1;i--)
	{
		nxt[i]=i+1;
		while(nxt[i]<=n&&(v[i]<v[nxt[i]]||iseq(v[i],v[nxt[i]]))) nxt[i]=nxt[nxt[i]];
		if(nxt[i]>n) {t[i]=1e14,pos[i]=x[i]; continue;}
		int to=nxt[i];
		ld tt=(x[to]-x[i]-(s[to]-s[i]))/(v[i]-v[to]);
		if(tt>t[to]||iseq(tt,t[to]))
		{
			for(int j=16;j>=0;j--)
			{
				int k=p[nxt[i]][j];
				if(!k) continue;
				tt=(x[k]-x[i]-(s[k]-s[i]))/(v[i]-v[k]);
				if(tt>t[k]||iseq(tt,t[k])) to=k;
			}
			to=p[to][0];
		}
		p[i][0]=to;
		t[i]=(x[to]-x[i]-(s[to]-s[i]))/(v[i]-v[to]);
		pos[i]=x[i]+v[i]*t[i];
		for(int j=1;1<<j<=n;j++) p[i][j]=p[p[i][j-1]][j-1];
	}
	for(int i=1;i<=n;i++)
	{
		ld l=0,r=1e14,mid,tt=0;
		while(!iseq(l,r))
		{
			mid=(l+r)/2;
			if(mid*V<ask(i,mid)-d[i]) tt=mid,l=mid;
			else r=mid;
		}
		ld L=ask(i,tt)-d[i]-ask(i-1,tt);
		if(i==1||L>D) ans++;
	}
	printf("%d",ans);
	return 0;
}
/*
3 1 10 1
2 1 5 1
8 1 4 1
10 1 2 1
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 135ms
memory: 11912kb

input:

100000 9 445 874
1653 9 34 792
2736 336 34 792
21599 862 34 792
23975 188 34 792
41891 401 34 792
62576 193 34 792
74285 567 34 792
78959 2850 34 792
85316 452 34 792
92188 217 34 792
97244 3526 34 792
106804 599 34 792
112500 1352 34 792
120610 581 34 792
123644 213 34 792
123754 16 34 792
125589 4...

output:

99889

result:

wrong answer 1st lines differ - expected: '99905', found: '99889'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 35
Accepted
time: 0ms
memory: 12096kb

input:

1000 5 716 3
632 108 255 785
1891 115 699 140
2143 130 778 315
3409 155 450 486
7330 57 351 675
10955 24 959 657
13151 127 37 429
13903 115 749 82
15213 37 267 276
15906 168 971 23
17068 74 751 600
18435 207 306 662
18493 4 463 490
18882 60 381 293
22184 64 888 663
27168 89 962 190
28751 121 122 898...

output:

527

result:

ok single line: '527'

Test #16:

score: 0
Accepted
time: 3ms
memory: 7912kb

input:

1000 20 917 8
1820 78 441 641
3590 90 486 512
6487 194 536 942
7056 123 266 270
8508 87 130 622
8990 30 654 463
10808 23 741 79
10932 27 228 776
11215 111 458 864
11778 38 751 153
12021 15 321 435
12053 9 162 741
12341 120 496 802
14246 23 431 808
16027 7 508 119
18356 168 362 909
20542 68 465 53
21...

output:

416

result:

ok single line: '416'

Test #17:

score: 0
Accepted
time: 3ms
memory: 9860kb

input:

1000 941 795 2
2446 276 652 673
3067 23 907 79
4023 57 20 189
4076 10 22 364
4263 46 101 752
4508 23 680 464
4777 178 638 58
5426 15 674 162
5537 43 75 564
5882 163 753 662
8162 125 142 638
9026 35 862 797
9117 57 689 398
11859 83 584 712
13277 17 897 881
13389 36 638 525
13790 20 763 810
16538 117 ...

output:

373

result:

ok single line: '373'

Test #18:

score: 0
Accepted
time: 3ms
memory: 10052kb

input:

1000 2625 10 1
477305 370 10 7
1151540 1000 7 10
1893809 12 9 1
3502666 718 4 6
3611320 296 6 6
5699350 260 3 8
8394591 596 3 10
8668961 750 2 4
11183997 981 8 7
13008836 37 10 8
14044159 2729 2 3
14287006 121 1 3
15373289 938 8 1
15724757 1165 1 4
16641191 1541 9 6
16980331 1060 7 3
17356572 4031 8...

output:

176

result:

ok single line: '176'

Test #19:

score: 0
Accepted
time: 4ms
memory: 11992kb

input:

1000 95619 10 1
26818 358 5 2
1122928 1616 6 3
1716816 175 7 10
3119287 836 9 3
3421179 3539 5 8
3570557 357 8 3
3790272 927 3 3
4240818 1211 1 9
5172443 1049 4 9
6239353 52 9 3
6675674 1504 5 3
8167258 66 9 1
9517371 2632 4 9
10547195 527 4 5
11014094 143 3 7
11841288 402 7 4
11968651 1527 5 1
1257...

output:

178

result:

ok single line: '178'

Test #20:

score: 0
Accepted
time: 3ms
memory: 9960kb

input:

1000 688304 10 1
620285 151 4 6
1034959 76 5 6
1225719 208 3 4
1713426 1012 6 7
3854628 1429 1 7
3927030 761 9 7
4437632 651 6 7
6426941 275 4 6
7028698 581 2 8
10549176 267 8 5
11653349 431 1 1
12080963 1598 6 4
13450599 672 10 5
15247541 747 7 7
15264944 2386 8 4
18172172 403 2 4
18625291 352 2 6
...

output:

161

result:

ok single line: '161'

Test #21:

score: 0
Accepted
time: 3ms
memory: 9860kb

input:

1000 1000000 10 1
2936901 3583 8 3
4644448 1954 4 3
5097512 417 10 9
5811378 323 2 6
6649104 220 8 7
7757879 327 4 5
8882610 1914 7 10
10770045 192 9 1
11903208 1663 1 4
12418289 272 9 4
12915573 195 2 5
14421535 356 3 5
14548681 2142 1 3
15042434 1059 4 5
15846240 2657 9 9
18290147 744 4 2
18982461...

output:

147

result:

ok single line: '147'

Test #22:

score: 0
Accepted
time: 0ms
memory: 11976kb

input:

1 1000000000 520 597
1000000000 1 780 953

output:

1

result:

ok single line: '1'

Test #23:

score: 0
Accepted
time: 3ms
memory: 10036kb

input:

1000 1 422 1
1095880 16014 3 841
1298884 76349 5 762
1702910 111571 5 568
1912705 25792 9 830
3745225 105212 9 728
3781023 30467 11 821
10618469 1096 13 907
11803677 82134 8 535
12637880 22279 6 391
13484141 76745 15 854
14951827 5716 10 543
15505787 232803 13 598
18572957 581420 10 457
20108441 712...

output:

933

result:

ok single line: '933'

Test #24:

score: 0
Accepted
time: 3ms
memory: 12120kb

input:

1000 27 605 2
1191466 54930 2 658
1613580 23200 3 715
1962744 24271 5 774
5027396 61091 3 416
5262460 76466 3 318
5462017 38352 5 514
5662349 13044 7 627
7902840 45266 10 879
8627486 150735 3 253
10770123 38265 14 949
12223404 97148 11 692
13090647 30038 13 712
14117271 100358 4 207
14322056 56073 2...

output:

949

result:

ok single line: '949'

Test #25:

score: 0
Accepted
time: 3ms
memory: 12120kb

input:

1000 489 576 2
438069 158776 2 680
896880 30966 4 777
2877163 246055 5 822
3774194 149311 4 629
4484416 71503 8 904
5441560 280164 5 514
5782141 63987 9 827
6312864 16095 11 889
6816587 23988 12 925
7516219 336352 2 111
7969756 288358 11 573
8515585 134018 13 588
8972225 46577 11 477
9799954 62797 1...

output:

951

result:

ok single line: '951'

Test #26:

score: 0
Accepted
time: 0ms
memory: 10096kb

input:

1000 4113 10 1
869434 77 1 10
1776850 445 1 10
2302328 2 1 10
3249965 216 7 6
3828364 595 1 10
8371011 754 1 9
8390016 62 1 9
10409005 668 1 9
10942850 179 1 9
11197527 3047 1 9
11265410 2071 1 9
11960682 152 1 8
12592083 3229 1 8
14640521 3919 1 8
17632213 194 1 8
18488270 837 1 8
19259259 147 1 8
...

output:

613

result:

ok single line: '613'

Test #27:

score: 0
Accepted
time: 0ms
memory: 9956kb

input:

1000 95698 10 1
1066719 292 1 10
3705384 1683 1 10
3801293 1773 1 10
6188356 1084 1 10
6309758 746 1 10
6877872 1506 1 10
7597138 1022 1 10
7851504 1409 1 10
9479948 689 1 10
10160908 671 1 10
11748366 930 1 10
12647207 1559 1 10
12896307 576 1 10
13777984 965 1 10
14977389 31 1 10
15072854 63 1 9
1...

output:

508

result:

ok single line: '508'

Test #28:

score: 0
Accepted
time: 3ms
memory: 11888kb

input:

1000 164349 10 1
1843692 789 1 10
2961691 1175 1 10
4644838 916 1 10
5743333 1840 1 10
5787040 225 1 10
7878423 3245 1 10
8542061 126 1 10
8920175 201 1 10
9122458 483 1 10
10402874 1156 1 10
11254248 456 1 10
12296407 554 1 10
13627737 1025 1 10
14062934 56 1 10
15916407 138 1 10
16521950 1065 1 10...

output:

502

result:

ok single line: '502'

Test #29:

score: -35
Wrong Answer
time: 0ms
memory: 9960kb

input:

1000 999000 3 1
2160793 1003 1 2
3160863 1071 1 2
3865062 496 1 2
6138641 470 1 2
7137768 128 1 2
8138166 1400 1 2
8457449 505 1 2
9456512 65 1 2
10456359 847 1 2
11455513 156 1 2
12172673 417 1 2
13049976 5 1 2
14049235 261 1 2
15049075 841 1 2
15373229 1208 1 2
15487309 81 1 2
16486620 313 1 2
174...

output:

75

result:

wrong answer 1st lines differ - expected: '155', found: '75'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%