QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#668906 | #9242. An Easy Geometry Problem | ruoye123456 | WA | 5ms | 3788kb | C++20 | 2.7kb | 2024-10-23 16:32:08 | 2024-10-23 16:32:08 |
Judging History
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 <= 10; ++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: 3760kb
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: 5ms
memory: 3788kb
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 356 75 38 69 310 152 59 124 105 7 5 55 97 3 118 70 31 36 341 30 30 17 21 361 12 17 1 33 7 19 106 8 44 51 13 7 51 44 98 50 142 58 74 22 36 6 201 79 82 280 114 124 34 3 81 21 23 53 94 106 36 2 29 23 40 32 133 45 336 27 38 105 159 2 36 179 198 150 69 24 78 37 15 30 196 123 28 87 15 11 15 157 2 37 39 ...
result:
wrong answer 2nd numbers differ - expected: '304', found: '356'