QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#668925 | #9242. An Easy Geometry Problem | ruoye123456 | WA | 15ms | 3752kb | C++20 | 2.9kb | 2024-10-23 16:35:58 | 2024-10-23 16:37:40 |
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 <= 100; ++i)
{
int x = rand()%M + 1;
if(A.sum(u + x) - A.sum(u - x) != k * x + b) return false;
}
for(int i = 0;i <= 100 && M - i >= 1; ++i)
{
int x = M - i;
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();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
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: 15ms
memory: 3712kb
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 17 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 46 43 16 1 72 33 16 22 5 6 189 27 1 192 107 43 34 3 27 20 21 44 56 96 36 2 27 22 30 32 6 5 105 27 37 12 58 2 21 154 17 110 57 3 7 33 15 24 94 68 25 1 14 10 4 10 2 25 39 36 33 164 11 19 181 11 ...
result:
wrong answer 51st numbers differ - expected: '35', found: '192'