QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#668936 | #9242. An Easy Geometry Problem | ruoye123456 | WA | 17ms | 3760kb | C++20 | 2.9kb | 2024-10-23 16:39:17 | 2024-10-23 16:39:19 |
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: 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: 0
Accepted
time: 11ms
memory: 3720kb
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 35 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 3...
result:
ok 3337 numbers
Test #3:
score: -100
Wrong Answer
time: 17ms
memory: 3700kb
input:
5000 5000 2 0 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 86...
output:
362 82 14 234 140 5 44 136 22 43 29 96 59 23 25 61 193 22 39 39 23 192 48 76 100 58 120 24 12 106 32 48 73 63 357 16 136 10 28 15 84 30 65 1 54 15 16 70 1 95 74 14 17 20 36 254 22 29 70 172 106 2 25 8 98 35 169 16 2 2 99 10 36 40 3 69 272 170 219 12 79 26 78 100 10 167 140 70 34 17 23 21 55 10 6 17 ...
result:
wrong answer 22nd numbers differ - expected: '53', found: '192'