QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#611684#9242. An Easy Geometry Problemduckindog#WA 7ms5880kbC++231.7kb2024-10-04 22:06:392024-10-04 22:06:40

Judging History

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

  • [2024-10-04 22:06:40]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:5880kb
  • [2024-10-04 22:06:39]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = 200'000 + 10;
int n, q, k, b;

int f[N << 2], lazy[N << 2];
inline void push(int s, int l, int r) { 
  int mid = (l + r) >> 1;
  f[s << 1] += (mid - l + 1) * lazy[s];   f[s << 1 | 1] += (r - mid) * lazy[s];
  lazy[s << 1] += lazy[s];                lazy[s << 1 | 1] += lazy[s];
  lazy[s] = 0;
}

void update(int s, int l, int r, int u, int v, int x) { 
  if (v < l || u > r) return;
  if (u <= l && r <= v) { 
    f[s] += (r - l + 1) * x;
    lazy[s] += x;
    return;
  }
  push(s, l, r);
  int mid = (l + r) >> 1;
  update(s << 1, l, mid, u, v, x);  update(s << 1 | 1, mid + 1, r, u, v, x);
  f[s] = f[s << 1] + f[s << 1 | 1];
}
int query(int s, int l, int r, int u, int v) { 
  if (v < l || u > r) return 0;
  if (u <= l && r <= v) return f[s];
  push(s, l, r);
  int mid = (l + r) >> 1;
  return query(s << 1, l, mid, u, v) + query(s << 1 | 1, mid + 1, r, u, v);
}

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);

  cin >> n >> q >> k >> b;
  for (int i = 1; i <= n; ++i) { 
    int x; cin >> x;
    update(1, 1, n, i, i, x);
  }

  while (q--) { 
    int type; cin >> type;

    if (type == 1) { 
      int l, r, x; cin >> l >> r >> x;
      update(1, 1, n, l, r, x);
    } else { 
      int i; cin >> i;

      int l = 1, r = min(i - 1, n - i), ret = 0;
      while (l <= r) { 
        int mid = (l + r) >> 1;

        int value = k * (mid + 1) * mid / 2 + b * mid;
        if (query(1, 1, n, i + 1, i + mid) - query(1, 1, n, i - mid, i - 1) 
            == value) l = (ret = mid) + 1;
        else r = mid - 1;
      }

      cout << ret << "\n";
    }
  }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5632kb

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

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
138
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
310
27
37
12
58
62
21
154
17
110
57
3
7
33
15
24
94
68
25
115
14
10
95
37
2
25
39
36
33
164
11
19
181...

result:

wrong answer 42nd numbers differ - expected: '72', found: '138'