답안 #38636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38636 2018-01-05T07:48:55 Z grumpy_gordon Simple game (IZhO17_game) C++14
22 / 100
19 ms 6476 KB
/*
                     .:*+=%@@@@@@=-.
                 .:=@#@@@#@@#######%==*.
              .-=####@######%*-.....:%##%.
            .*@###########%+:--........-%@-
          .*@##############@+--.........-:%-
        .+##################@==%%%%=+*:----+.
      .-@####################%++%@@@@@=+**%@@*
      .%###################@%%@@@###@%+:--%@@%.
     -@###################@%%%%*::*%++:-----=@+.
    -#####################@%=++++++*:-------.-=:
   .+####################@%++*::-:::--::*:::***=:
   .@#####################%=++*::::-:::++*=##@@#@-
  ..#####################@%%=++**:::::**+%@#@%%##-..
   .%####################@@%=+++*+****::*=@######@.
  .=######################@%%==+==++**+=@%@##@###+:...
  -#######################@@@%%%===++=@@@%=++===*::--...
  -########################@@@@@@@%==%%=++==@@:::::*:--.
..:#########################@@@@@@%%======++++::-..:-.--...
%#############################@###@%%@@%==%=%*----.--.::---.
#############################################*-:*:-:---*---- .
#############################################*--*--:---*---:-.
#############################################+--::--::-*::-::.
###########################################+:*-.---.---.:---*-..
###########################################**:-----------------.
##########################################@::**:--::::::--:::::-
###########################################:--:*:::::::::**::*+*
###########################################=:::***::::::**:::*+*
############################@@@@@@#########@+****::::********+++
############################@%%%%%@@@@@@@###%+***::::::::***+==+
############################@%%%%%%%%%%%@####=+:::-::::-::*+=%%+
#############################@%%%%%%%%%%@#####=::--------:*=%@%+
%###########################@%%%%==%%%%%%@##@#=:------..-:+%@@%=
----------------------------------------------
--------------------------------------------
----------------------------------------------
--------------------------------------------
----------------------------------------------

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/
#include <bits/stdc++.h>

//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
//float __attribute__((aligned(32)))

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

int mysqrt(ll x){
    int l = 0, r = 1e9 + 1;
    while (r - l > 1){
        int m = (l + r) / 2;
        if (m * (ll)m <= x)
            l = m;
        else
            r = m;
    }
    return l;
}

mt19937 rnd(1337);

ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MODR = 1e9 + 993;

ll myrand(){
    ll ZR = (XR * AR + YR * BR + CR) % MODR;
    XR = YR;
    YR = ZR;
    return ZR;
}

const int Mod = 1e9 + 7;

int bpow(int x, int y){
    if (y == 0)
        return 1;
    if (y == 1)
        return x;
    int ret = bpow(x, y >> 1);
    ret = (ret * (ll)ret) % Mod;
    if (y & 1)
        ret = (ret * (ll)x) % Mod;
    return ret;
}

int bdiv(int x, int y){
    return (x * (ll)bpow(y, Mod - 2)) % Mod;
}

void setmin(int &x, int y){
    x = min(x, y);
}

void setmax(int &x, int y){
    x = max(x, y);
}

const ll llinf = 1e18 + 100;

const int maxn = 1e5 + 100, maxw = 1e6 + 100, inf = 2e9 + 100, sq = 300, mod = 1e9 + 7, LG = 17;

int n, zap;

int fen[maxw];

int a[maxn];

void inc(int i, int v){
    for (; i < maxw; i = (i | (i + 1)))
        fen[i] += v;
}

int get(int i){
    int ret = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1)
        ret += fen[i];
    return ret;
}

int main()
{
    #ifdef ONPC
    //ifstream cin("a.in");
    //ofstream cout("a.out");
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #else
    //ifstream cin("money.in");
    //ofstream cout("money.out");
    //freopen("money.in", "r", stdin);
    //freopen("money.out", "w", stdout);
    #endif // ONPC
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> zap;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if (i)
            inc(min(a[i], a[i - 1]), 1), inc(max(a[i], a[i - 1]), -1);
    }
    while (zap--){
        int t;
        cin >> t;
        if (t == 1){
            int id, v;
            cin >> id >> v;
            id--;
            if (id)
                inc(min(a[id], a[id - 1]), -1), inc(max(a[id], a[id - 1]), 1);
            if (id < n - 1)
                inc(min(a[id], a[id + 1]), -1), inc(max(a[id], a[id + 1]), 1);
            a[id] = v;
            if (id)
                inc(min(a[id], a[id - 1]), 1), inc(max(a[id], a[id - 1]), -1);
            if (id < n - 1)
                inc(min(a[id], a[id + 1]), 1), inc(max(a[id], a[id + 1]), -1);
        }
        else{
            int v;
            cin >> v;
            cout << get(v) << '\n';
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6476 KB Output is correct
2 Correct 3 ms 6476 KB Output is correct
3 Correct 0 ms 6476 KB Output is correct
4 Correct 0 ms 6476 KB Output is correct
5 Correct 0 ms 6476 KB Output is correct
6 Correct 0 ms 6476 KB Output is correct
7 Correct 0 ms 6476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6476 KB Output is correct
2 Correct 3 ms 6476 KB Output is correct
3 Correct 0 ms 6476 KB Output is correct
4 Correct 0 ms 6476 KB Output is correct
5 Correct 0 ms 6476 KB Output is correct
6 Correct 0 ms 6476 KB Output is correct
7 Correct 0 ms 6476 KB Output is correct
8 Runtime error 19 ms 6476 KB Execution killed because of forbidden syscall writev (20)
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6476 KB Output is correct
2 Correct 3 ms 6476 KB Output is correct
3 Correct 0 ms 6476 KB Output is correct
4 Correct 0 ms 6476 KB Output is correct
5 Correct 0 ms 6476 KB Output is correct
6 Correct 0 ms 6476 KB Output is correct
7 Correct 0 ms 6476 KB Output is correct
8 Runtime error 19 ms 6476 KB Execution killed because of forbidden syscall writev (20)
9 Halted 0 ms 0 KB -