QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#668908#9242. An Easy Geometry Problemruoye123456WA 14ms3784kbC++202.7kb2024-10-23 16:32:512024-10-23 16:32:52

Judging History

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

  • [2024-10-23 16:32:52]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3784kb
  • [2024-10-23 16:32:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<string> VS;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
vector<int> vx;
inline void divide() {sort(vx.begin(),vx.end());vx.erase(unique(vx.begin(),vx.end()),vx.end());}
//inline int mp(int x) {return upper_bound(vx.begin(),vx.end(),x)-vx.begin();}
inline int log_2(int x) {return 31-__builtin_clz(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int lowbit(int x) {return x&-x;}
inline ll Lsqrt(ll x) { ll L = 1,R = 2e9;while(L + 1 < R){ll M = (L+R)/2;if(M*M <= x) L = M;else R = M;}return L;}
const int N = 2e5+10;
template <class T>
struct BIT
{
	T c[N];
	int sz;
	void init(int s)
	{
		sz = s;
		for(int i=1;i<=sz;++i) c[i] = 0;
	}
	T lowbit(int x)
	{
		return x&-x;
	}
	T sum(int x) 
	{
		assert(x <= sz);
		T res=0;
		while(x) res+=c[x],x-=lowbit(x);
		return res;
	}
	void update(int x,int y) 
	{
		assert(x != 0);
		while(x<=sz) c[x]+=y,x+=lowbit(x);
	}
};
BIT<int> A; 
void solve()
{
    srand(time(0));
    int n,q,k,b;
    cin>>n>>q>>k>>b;
    A.init(n);
    for(int i=1;i<=n;++i)
    {
        int a;
        cin>>a;
        A.update(i,a);
        A.update(i+1,-a);
    }
    for(int i=1;i<=q;++i)
    {
        int op;
        cin>>op;
        if(op&1)
        {
            int l,r,v;
            cin>>l>>r>>v;
            A.update(l,v);
            A.update(r+1,-v);
        }
        else
        {
            int u;
            cin>>u;
            //int w = A.sum(u);
            int res = 0;
            if(u + 1 <= n && u - 1 > 0 && A.sum(u + 1) - A.sum(u - 1) == k + b)
            {
                int L = 1, R = n;
                auto check = [&](int M)->bool
                {
                    if(u + M > n || u - M <= 0) return false;
                    for(int i = 1;i <= 100; ++i)
                    {
                        int x = rand()%M + 1;
                        if(A.sum(u + x) - A.sum(u - x) != k * x + b) return false;
                    }
                    return true;
                };
                while(L + 1 < R)
                {
                    int M = (L + R)/2;
                    if(check(M)) L = M;
                    else R = M;
                }
                res = L;
            }
            else
            {
                res = 0;
            }
            cout<<res<<'\n';
        }
    }
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3696kb

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: 14ms
memory: 3784kb

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
293
142
48
84
99
6
5
53
93
3
91
65
29
33
307
21
24
17
21
283
12
16
1
33
7
18
97
7
40
39
13
7
46
43
16
1
73
33
16
22
5
6
189
27
1
35
108
43
34
3
27
20
21
44
88
96
36
2
27
22
31
32
6
5
314
27
37
12
58
2
21
157
17
128
58
3
88
33
15
24
94
79
25
1
14
10
4
10
2
25
39
160
33
165
11
19
181
11...

result:

wrong answer 6th numbers differ - expected: '292', found: '293'