Submission #505361

#TimeUsernameProblemLanguageResultExecution timeMemory
505361mansurSimple game (IZhO17_game)C++17
100 / 100
212 ms19840 KiB
#include<bits/stdc++.h> #pragma optimize ("g",on) #pragma GCC optimize ("inline") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") #pragma comment(linker, "/stack:200000000") //01001101 01100001 01101011 01101000 01100001 01100111 01100001 01111001 using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ll long long #define pb push_back #define sz(a) a.size() #define nl '\n' #define popb pop_back() #define ld double #define ull unsigned long long #define ff first #define ss second #define fix fixed << setprecision #define pii pair<int, int> #define E exit (0) #define int long long const int inf = 1e9, N = 1e6 + 1, mod = 998244353; vector<pii> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int t[4 * N]; void update(int u, int tl, int tr, int l, int r, int val) { if (tl > r || tr < l) return; if (tl >= l && tr <= r) { t[u] += val; return; } int mid = (tl + tr) / 2; update(u * 2, tl, mid, l, r, val); update(u * 2 + 1, mid + 1, tr, l, r, val); } int get(int u, int tl, int tr, int pos) { if (tl == tr) return t[u]; int mid = (tl + tr) / 2; if (pos <= mid) return get(u * 2, tl, mid, pos) + t[u]; return get(u * 2 + 1, mid + 1, tr, pos) + t[u]; } main() { //freopen("cowrect.in", "r", stdin); //freopen("cowrect.out", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(NULL); int n, m; cin >> n >> m; int y[n + 1]; for (int i = 1; i <= n; i++) { cin >> y[i]; if (i > 1) { update(1, 1, N - 1, min(y[i - 1], y[i]), max(y[i - 1], y[i]), 1); } } while (m--) { int tp; cin >> tp; if (tp == 1) { int i, val; cin >> i >> val; if (i > 1) update(1, 1, N - 1, min(y[i - 1], y[i]), max(y[i - 1], y[i]), -1); if (i < n) update(1, 1, N - 1, min(y[i + 1], y[i]), max(y[i + 1], y[i]), -1); y[i] = val; if (i > 1) update(1, 1, N - 1, min(y[i - 1], y[i]), max(y[i - 1], y[i]), 1); if (i < n) update(1, 1, N - 1, min(y[i + 1], y[i]), max(y[i + 1], y[i]), 1); }else { int h; cin >> h; cout << get(1, 1, N - 1, h) << nl; } } }

Compilation message (stderr)

game.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      | 
game.cpp:9: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    9 | #pragma comment(linker, "/stack:200000000")
      | 
game.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...