QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312690#5264. Wyprzedzanietuxuanming20240 123ms12076kbC++141.4kb2024-01-24 10:44:532024-01-24 10:44:55

Judging History

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

  • [2024-01-24 10:44:55]
  • 评测
  • 测评结果:0
  • 用时:123ms
  • 内存:12076kb
  • [2024-01-24 10:44:53]
  • 提交

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-9;
int n,D,d[N],x[N],nxt[N],p[N][18],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 x,ld tt)
{
	int y=x;
	for(int i=17;i>=0;i--)
		if(p[y][i]&&(t[p[y][i]]<tt||iseq(t[p[y][i]],tt))) y=p[y][i];
	return pos[y]+v[y]*(tt-t[y])-(s[y]-s[x]);
}
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]=1e13;
	for(int i=n-1;i>=1;i--)
	{
		nxt[i]=i+1;
		while(v[i]<v[nxt[i]]||iseq(v[i],v[nxt[i]])) nxt[i]=nxt[nxt[i]];
		if(nxt[i]>n) {t[i]=1e13; continue;}
		int to=-1;
		for(int j=17;j>=0;j--)
		{
			int k=p[nxt[i]][j];
			if(!k) continue;
			ld tt=(x[k]-x[i]-(s[k]-s[i]))/(v[i]-v[k]);
			if(tt>t[k]||iseq(tt,t[k])) to=k;
		}
		to=to==-1?nxt[i]: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=1e13,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||iseq(L,D)) ans++;
	}
	printf("%d",ans);
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 123ms
memory: 11360kb

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:

1

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 4ms
memory: 12076kb

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:

558

result:

wrong answer 1st lines differ - expected: '527', found: '558'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%