QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#726461 | #9242. An Easy Geometry Problem | rtgsp | WA | 5ms | 9932kb | C++20 | 2.7kb | 2024-11-09 01:05:54 | 2024-11-09 01:05:55 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define task ""
using namespace std;
const ll maxn = 2e5 + 2, mod = 1e9 + 7, base = 998244353, inf = 1e18;
ll n, q, k, b, l, r, v, ok, a[maxn], p[maxn], st[2][4*maxn];
void build (int node, int l, int r)
{
if (l == r)
{
st[0][node] = st[1][node] = a[l] % mod;
return;
}
int mid = (l + r)/2;
build(2*node, l, mid);
build(2*node + 1, mid + 1, r);
st[0][node] = (st[0][2*node] + st[0][2*node + 1]*p[mid - l + 1]) % mod;
st[1][node] = (st[1][2*node]*p[r - mid] + st[1][2*node + 1]) % mod;
}
void update (int node, int l, int r, int idx, ll val)
{
if (l == r)
{
st[0][node] = (st[0][node] + val)%mod;
st[1][node] = (st[1][node] + val)%mod;
return;
}
int mid = (l + r)/2;
if (idx <= mid) update(2*node, l, mid, idx, val);
else update(2*node + 1, mid + 1, r, idx, val);
st[0][node] = (st[0][2*node] + st[0][2*node + 1]*p[mid - l + 1]) % mod;
st[1][node] = (st[1][2*node]*p[r - mid] + st[1][2*node + 1]) % mod;
}
ll get (int t, int node, int l, int r, int cl, int cr)
{
if (cr < l || r < cl) return 0;
if (cl <= l && r <= cr)
{
if (t == 0) return p[l - cl]*st[t][node];
else return p[cr - r]*st[t][node];
}
int mid = (l + r)/2;
return get(t, 2*node, l, mid, cl, cr) + get(t, 2*node + 1, mid + 1, r, cl, cr);
}
int main()
{
//freopen(task".INP", "r", stdin);
//freopen(task".OUT", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> q >> k >> b;
b = 2*b;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
a[i] = 2*a[i] - i*k;
}
for (int i = n; i >= 1; i--) a[i] -= a[i - 1];
p[0] = 1;
for (int i = 1; i <= n; i++) p[i] = p[i - 1] * base % mod;
build(1, 1, n);
while (q--)
{
cin >> ok;
if (ok == 1)
{
cin >> l >> r >> v;
v = 2*v;
update(1, 1, n, l, v);
if (r < n) update(1, 1, n, r + 1, -v);
}
else
{
cin >> ok;
if (ok == 1 || ok == n || get(0, 1, 1, n, ok, ok) + get(0, 1, 1, n, ok + 1, ok + 1) != b)
{
cout << 0 << '\n';
continue;
}
ll low = 2, high = min(ok - 1, n - ok), mid;
while (low <= high)
{
mid = (low + high)/2;
if (get(0, 1, 1, n, ok - mid + 1, ok - 1) != -get(1, 1, 1, n, ok + 2, ok + mid)) high = mid - 1;
else low = mid + 1;
}
cout << high << '\n';
}
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7752kb
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: 9932kb
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:
wrong answer 349th numbers differ - expected: '25', found: '2'