UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#215508#2077. patrickCynops501325ms5260kbC++1.2kb2025-02-14 08:14:542025-02-14 08:14:56

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define rep(i,l,r) for (int i = l; i <= r; i ++)
#define rrp(i,l,r) for (int i = l; i >= r; i --)
const int N = 1e6 + 5;
int n, m, lst, a[N];
struct bit {
  int c[N];
  void add (int x, int v) {
    for (; x <= n+1; x += x & (-x)) c[x] += v;
  }
  void upd (int i, int v) { 
    if (a[i-1] < a[i]) add(a[i-1], v), add(a[i], -v);
  }
  int sum(int x) {
    int ans = 0;
    for (; x; x -= x & (-x)) ans += c[x];
    return ans;
  }
} t;
void fakemain() {
  cin >> n >> m, a[0] = 1;
  rep (i, 1, n) cin >> a[i], ++ a[i], t.upd(i, 1);
  rep (i, 1, m) {
    char op; int x, y;
    cin >> op >> x, x ^= lst;
    if (op == 'Q') cout << (lst = t.sum(x)) << '\n';
    else {
      cin >> y, y ^= lst, ++ y;
      t.upd(x, -1), t.upd(x + 1, -1);
      a[x] = y, t.upd(x, 1), t.upd(x + 1, 1);
    }
  }
}
signed main() {
#ifdef heige
  freopen("patrick.in", "r", stdin);
  freopen("patrick.out", "w", stdout);
#endif
  cin.tie(0)->ios::sync_with_stdio(0);
  int T = 1;
  while (T --) fakemain();
  cerr << 1. * clock() / 1000000 << "s\n";
  return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 0
Time Limit Exceeded

input:

5000 5000
11618 17338 26007 30645 41495 8577 28220 3557 61048 54271 12735 30554 19117 24912 71916 49...

output:


result:


Test #2:

score: 0
Time Limit Exceeded

input:

5000 5000
42781 68835 20862 71700 5933 7140 30423 64165 68706 48054 21418 34952 36459 97560 1772 607...

output:


result:


Test #3:

score: 0
Time Limit Exceeded

input:

5000 5000
60808 84070 31811 47365 75619 62284 2581 79641 72061 80156 33934 16942 25000 66064 57202 5...

output:


result:


Test #4:

score: 10
Accepted
time: 219ms
memory: 5260kb

input:

500000 500000
434137 376219 73435 423036 76491 303408 102448 338828 69875 129478 243716 421147 31592...

output:

98072
121513
123051
2812
44889
104264
124972
123583
113689
56410
113385
108806
88021
112511
124641
2...

result:

ok 500000 lines

Test #5:

score: 10
Accepted
time: 184ms
memory: 5260kb

input:

500000 500000
327558 296576 192637 469428 399577 209259 271256 286868 410902 236457 141261 191443 26...

output:

5762
77131
81889
17491
32828
112750
124941
72798
124170
108653
77847
107448
31853
18930
77402
34449
...

result:

ok 500000 lines

Test #6:

score: 10
Accepted
time: 171ms
memory: 5256kb

input:

500000 500000
331273 70363 482686 148091 231329 25731 312057 350815 71400 129967 88289 442354 423136...

output:

53946
124566
124905
69402
124146
124976
92287
110542
120860
122557
120849
19871
104123
123390
21447
...

result:

ok 500000 lines

Test #7:

score: 0
Time Limit Exceeded

input:

100000 100000
452172 464888 314423 267249 442680 360343 19632 341976 115526 300385 18455 172824 3591...

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

100000 100000
92691 110061 365569 179484 447960 127240 193963 70505 338364 452003 66473 63721 407006...

output:


result:


Test #9:

score: 10
Accepted
time: 349ms
memory: 5260kb

input:

500000 500000
230546 43633 320357 293808 381361 136978 286284 379946 367590 183794 362424 147508 246...

output:

79022
87923
6292
32428
37116
125126
82270
118323
43719
113469
82845
14057
18792
118967
93087
38413
2...

result:

ok 249940 lines

Test #10:

score: 10
Accepted
time: 402ms
memory: 5260kb

input:

500000 500000
358202 474862 444709 448091 30620 234558 269129 267684 405954 191727 347456 97683 2255...

output:

93019
84369
32373
125041
112262
30223
33014
60264
77768
23
91412
32835
116289
97805
59930
105620
656...

result:

ok 249954 lines