Submission #1085572

# Submission time Handle Problem Language Result Execution time Memory
1085572 2024-09-08T12:34:46 Z coolboy19521 Simple game (IZhO17_game) C++17
0 / 100
0 ms 348 KB
#include "bits/stdc++.h"
#define ll long long

using namespace std;

const int sz = 1e5 + 5;

int fw[sz], a[sz];
int n;

void add(int v, int k) {
    for (; v <= n; v += v & -v)
        fw[v] += k;
}

int qry(int hi) {
    int r = 0;
    for (; 0 < hi; hi -= hi & -hi)
        r += fw[hi];
    return r;
}

void relax(int v, int k) {
    int r = v - 1;
    if (a[r] < a[v])
        add(a[r] + 1, k);
    else if (a[r] > a[v])
        add(a[v] + 1, k);
}

int main() {
    int m; cin >> n >> m;
    for (int i = 1; i <= n; i ++)
        cin >> a[i];
    for (int i = 1; i <= n; i ++)
        relax(i, 1);
    while (m --) {
        int t; cin >> t;
        if (1 == t) {
            int p, v; cin >> p >> v;
            int l = a[p];
            for (int i : {0, 1}) {
                if (1 == p and 0 == i)
                    continue;
                relax(p + i, -1);
                a[p] = v;
                relax(p + i, 1);
                a[p] = l;
            }
            a[p] = v;
        } else {
            int x; cin >> x;
            cout << qry(x) << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -