QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#668891 | #9242. An Easy Geometry Problem | ruoye123456 | WA | 2ms | 3700kb | C++20 | 2.5kb | 2024-10-23 16:28:01 | 2024-10-23 16:28:01 |
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()
{
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;
return A.sum(u + M) - A.sum(u - M) == k * M + b;
};
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: 3700kb
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: 2ms
memory: 3656kb
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 116 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 49 43 79 48 138 65 67 22 118 6 189 71 84 247 107 114 34 3 79 20 21 53 91 96 36 27 27 22 30 32 151 40 310 27 62 116 145 62 74 154 176 171 57 78 90 33 15 24 155 119 25 115 14 10 95 133 2 34 39 ...
result:
wrong answer 9th numbers differ - expected: '17', found: '116'