QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#726465#9242. An Easy Geometry ProblemrtgspWA 6ms9924kbC++202.6kb2024-11-09 01:09:472024-11-09 01:09:48

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 01:09:48]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:9924kb
  • [2024-11-09 01:09:47]
  • 提交

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;
unsigned 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];
        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];
    st[1][node] = st[1][2*node]*p[r - mid] + st[1][2*node + 1];
}
void update (int node, int l, int r, int idx, ll val)
{
    if (l == r)
    {
        st[0][node] = st[0][node] + val;
        st[1][node] = st[1][node] + val;
        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];
    st[1][node] = st[1][2*node]*p[r - mid] + st[1][2*node + 1];
}
unsigned 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;
    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';
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9712kb

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: 6ms
memory: 9924kb

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 936th numbers differ - expected: '4', found: '18'