Submission #35057

# Submission time Handle Problem Language Result Execution time Memory
35057 2017-11-17T20:28:03 Z model_code Simple game (IZhO17_game) C++11
22 / 100
1000 ms 10676 KB
//Solution by Zhusupov Nurlan
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define endl '\n'
#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base LL(1e9 + 7)
#define fname "game."
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define mp make_pair
#define L(xx, yy) min((xx), (yy))
#define R(xx, yy) max((xx), (yy))

int n, m, v, T, x, a[sz];
multiset <PII> S;

int main()
{

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (i > 1) {
        S.insert(mp(L(a[i - 1], a[i]), R(a[i - 1], a[i])));
      }
    }
    for (int i = 1; i <= m; i++) {
      cin >> T;
      if (T == 1) {
        cin >> v >> x;
        if (v > 1)
          S.erase(S.find(mp(L(a[v - 1], a[v]), R(a[v - 1], a[v]))));
        if (v < n)
          S.erase(S.find(mp(L(a[v + 1], a[v]), R(a[v], a[v + 1]))));
        a[v] = x;
        if (v > 1)
          S.insert(mp(L(a[v - 1], a[v]), R(a[v - 1], a[v])));
        if (v < n)
          S.insert(mp(L(a[v], a[v + 1]), R(a[v], a[v + 1])));
      }
      if (T == 2) {
        cin >> x;
        int res = 0;
        multiset <PII> :: iterator it = S.lower_bound(mp(x, 0));
        while (1) {
          if (it != S.end())
            res += (*it).F <= x && x <= (*it).S;
          if (it == S.begin()) break;
          it--;
        }
        cout << res << "\n";
      }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 9 ms 5924 KB Output is correct
3 Correct 3 ms 5924 KB Output is correct
4 Correct 6 ms 5924 KB Output is correct
5 Correct 13 ms 5924 KB Output is correct
6 Correct 6 ms 5924 KB Output is correct
7 Correct 26 ms 5924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 9 ms 5924 KB Output is correct
3 Correct 3 ms 5924 KB Output is correct
4 Correct 6 ms 5924 KB Output is correct
5 Correct 13 ms 5924 KB Output is correct
6 Correct 6 ms 5924 KB Output is correct
7 Correct 26 ms 5924 KB Output is correct
8 Execution timed out 1000 ms 10676 KB Execution timed out
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 9 ms 5924 KB Output is correct
3 Correct 3 ms 5924 KB Output is correct
4 Correct 6 ms 5924 KB Output is correct
5 Correct 13 ms 5924 KB Output is correct
6 Correct 6 ms 5924 KB Output is correct
7 Correct 26 ms 5924 KB Output is correct
8 Execution timed out 1000 ms 10676 KB Execution timed out
9 Halted 0 ms 0 KB -