QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#550130#9242. An Easy Geometry Problemucup-team3555#WA 23ms11952kbC++201.5kb2024-09-07 09:58:482024-09-07 09:58:48

Judging History

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

  • [2024-09-07 09:58:48]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:11952kb
  • [2024-09-07 09:58:48]
  • 提交

answer

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

typedef long long ll;
typedef long long ull;
const ll N=2e5+3,H=1e9+97;
ll n,m,K,B,a[N],b[N];
ull bas=998244353,pw[N],ip[N],res[N];
ll Ksm(ll x,ll y)
{
	ll s=1;
	for(;y;y>>=1,x=x*x%H)if(y&1)s=s*x%H;
	return s;
}
struct BIT0
{
	ll tr[N];
	void Add(int x,ll y){for(;x<n;x+=x&-x)tr[x]=(tr[x]+y)%H;}
	ll Ask(int x){ll s=0;for(;x;x-=x&-x)s=(s+tr[x])%H;return s;}
	ll Ans(int l,int r){return (Ask(r)-Ask(l-1)+H)*ip[l]%H;}
}T0;
struct BIT1
{
	ll tr[N];
	void Add(int x,ll y){for(;x;x-=x&-x)tr[x]=(tr[x]+y)%H;}
	ll Ask(int x){ll s=0;for(;x<n;x+=x&-x)s=(s+tr[x])%H;return s;}
	ll Ans(int l,int r){return (Ask(l)-Ask(r+1)+H)*ip[n-r]%H;}
}T1;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>K>>B;pw[0]=res[0]=ip[0]=1;
	for(int i=1;i<N;i++)pw[i]=pw[i-1]*bas%H,res[i]=(res[i-1]+pw[i])%H,ip[i]=Ksm(pw[i],H-2);
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<n;i++)b[i]=a[i+1]-a[i];
	for(int i=1;i<n;i++)T0.Add(i,b[i]*pw[i]%H),T1.Add(i,b[i]*pw[n-i]%H);
	while(m--)
	{
		int op;cin>>op;
		if(op==1)
		{
			int l,r,d;cin>>l>>r>>d;
			if(l>1)b[l-1]+=d,T0.Add(l-1,(H+d)*pw[l-1]%H);
			if(r<n)b[r]-=d,T1.Add(r,(H-d)*pw[n-r]%H);
		}
		else
		{
			ll x;cin>>x;
			if(x==1||b[x-1]+b[x]!=K+B){cout<<0<<"\n";continue;}
			int l=1,r=min(x-1,n-x);
			while(l<r)
			{
				int mi=(l+r)/2+1;
				ll s0=T0.Ans(x-mi,x-1),s1=T1.Ans(x,x+mi-1);
				if((s0+s1)%H==(res[mi-1]*K+pw[mi-1]*B)%H)l=mi;
				else r=mi-1;
			}
			cout<<l<<"\n";
		}
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 23ms
memory: 9812kb

input:

6 6 6 2
1 5 9 10 15 18
2 2
1 3 3 -3
2 2
1 3 4 3
2 3
2 4

output:

1
0
2
0

result:

ok 4 number(s): "1 0 2 0"

Test #2:

score: -100
Wrong Answer
time: 22ms
memory: 11952kb

input:

5000 5000 2 0
-329 -328 -327 -326 -325 -324 -323 -322 -321 -320 -319 -318 -317 -316 -315 -314 -313 -312 -311 -310 -309 -308 -307 -306 -305 -304 -303 -302 -301 -300 -299 -298 -297 -296 -295 -294 -293 -292 -291 -290 -289 -288 -287 -286 -285 -284 -283 -282 -281 -280 -279 -278 -277 -276 -275 -274 -273 -...

output:

2
304
73
29
61
292
139
48
18
99
6
5
53
93
3
91
65
29
33
306
21
24
17
21
281
12
16
1
33
7
18
96
7
40
39
13
7
47
43
17
2
73
34
17
22
6
6
189
28
2
36
107
44
34
3
28
20
21
45
57
97
36
3
27
23
30
32
7
6
106
27
38
13
59
3
22
154
18
111
57
4
8
33
15
25
95
69
25
2
14
10
5
11
2
26
39
37
33
164
11
19
181
11
3...

result:

wrong answer 9th numbers differ - expected: '17', found: '18'