Submission #85875

# Submission time Handle Problem Language Result Execution time Memory
85875 2018-11-22T09:02:36 Z inom Simple game (IZhO17_game) C++14
0 / 100
2 ms 376 KB
#include<bits/stdc++.h>

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define in freopen("parking.in", "r", stdin);
#define out freopen("parking.out", "w", stdout);

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma warning(disable : 4996)

const int N = 100100;
const int INF = 1000100;

int TN = 1;

int n, m;
int a[N], t[INF + N];

void update(int v, int tl, int tr, int l, int r, int add) {
    if (l > r) {
        return;
    }
    if (tl == l && tr == r) {
        t[v] += add; return;
    }
    int tm = (tl + tr) >> 1;
    update(v << 1, tl, tm, l, min(r, tm), add); update(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r, add);
}

int get(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        return t[v];
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
        return get(v << 1, tl, tm, pos);
    }
    else {
        return get(v << 1 | 1, tm + 1, tr, pos);
    }
}

void solve() {
    // printf("%d\n", INF);
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    if (n == 1) {
        while (m--) {
            int type; scanf("%d", &type);
            if (type == 1) {
                int pos; scanf("%d %d", &pos, &a[1]);
            }
            else {
                int H; scanf("%d", &H);
                printf("%d\n", a[1] == H ? 1 : 0);
            }
        }
        return;
    }
    for (int i = 2; i <= n; i++) {
        update(1, 1, INF, min(a[i - 1], a[i]), max(a[i - 1], a[i]), 1);
    }
    while (m--) {
        int type; scanf("%d", &type);
        if (type == 1) {
            int pos, val; scanf("%d %d", &pos, &val);
            if (pos > 1) {
                update(1, 1, INF, min(a[pos - 1], a[pos]), max(a[pos - 1], a[pos]), -1);
                update(1, 1, INF, min(a[pos - 1], val), max(a[pos- 1], val), 1);
            }
            if (pos < n) {
                update(1, 1, INF, min(a[pos], a[pos + 1]), max(a[pos], a[pos + 1]), -1);
                update(1, 1, INF, min(a[pos + 1], val), max(a[pos + 1], val), 1);
            }
            a[pos] = val;
        }
        else {
            int H; scanf("%d", &H);
            printf("%d\n", get(1, 1, INF, H));
        }
    }
    return;
}

signed main() {
    // ios_base::sync_with_stdio(0);
    // in; out; // cin >> TN;
    while (TN--) solve();
    return 0;
 }

Compilation message

game.cpp:21:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable : 4996)
 
game.cpp: In function 'void solve()':
game.cpp:57:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
game.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
game.cpp:63:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int type; scanf("%d", &type);
                       ~~~~~^~~~~~~~~~~~~
game.cpp:65:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 int pos; scanf("%d %d", &pos, &a[1]);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~
game.cpp:68:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 int H; scanf("%d", &H);
                        ~~~~~^~~~~~~~~~
game.cpp:78:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int type; scanf("%d", &type);
                   ~~~~~^~~~~~~~~~~~~
game.cpp:80:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int pos, val; scanf("%d %d", &pos, &val);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~
game.cpp:92:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int H; scanf("%d", &H);
                    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -