Submission #83328

#TimeUsernameProblemLanguageResultExecution timeMemory
83328NordwaySimple game (IZhO17_game)C++14
0 / 100
1075 ms1716 KiB
#include<bits/stdc++.h> #define x first #define y second #define pb push_back #define mp make_pair #define up_b upper_bound #define low_b lower_bound #define sz(x) (int)x.size() #define all(v) v.begin(),v.end() #define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie() using namespace std; typedef unsigned long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; const ll INF = 1e18; const int inf = INT_MAX; const ll mod = 1e9 + 7; const int pi = acos(-1); const int dx[4] = {0, 1, 0, 0}; const int dy[4] = {1, 0, 0, 0}; const int N = 1e5 + 5; const int MAXN = 1e6 + 1; int t[4 * MAXN], a[N], z[4 * MAXN]; void push(int v, int tl, int tr){ if(z[v]){ if(tl != tr){ z[v * 2] += z[v]; z[v * 2 + 1] += z[v]; } t[v] += z[v]; z[v] = 0; } } void upd(int v, int tl, int tr, int l, int r, int val){ if(tl > r || l > tr)return; if(l <= tl && tr <= r){ z[v] += val; push(v, tl, tr); return ; } push(v, tl, tr); int tm = (tl + tr) / 2; upd(v * 2, tl, tm, l, r, val); upd(v * 2 + 1, tm + 1, tr, l, r, val); t[v] = t[v * 2] + t[v * 2 + 1]; } int get(int v, int tl, int tr, int pos){ push(v, tl, tr); if(tl == tr)return t[v]; int tm = (tl + tr) / 2; if(pos <= tm)return get(v * 2, tl, tm, pos); else return get(v * 2 + 1, tm + 1, tr, pos); } int main(){ freopen("game.in", "r", stdin); freopen("game.out", "w", stdout); int n, m; cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; if(i > 1){ upd(1, 1, 1e6, min(a[i], a[i - 1]), max(a[i], a[i - 1]), 1); } } while(m--){ int type, h, pos, val; cin >> type; if(type == 1){ cin >> pos >> val; if(pos != 1)upd(1, 1, 1e6, min(a[pos], a[pos - 1]), max(a[pos], a[pos - 1]), -1); if(pos != n)upd(1, 1, 1e6, min(a[pos], a[pos + 1]), max(a[pos], a[pos + 1]), -1); a[pos] = val; if(pos != 1)upd(1, 1, 1e6, min(a[pos], a[pos - 1]), max(a[pos], a[pos - 1]), 1); if(pos != n)upd(1, 1, 1e6, min(a[pos], a[pos + 1]), max(a[pos], a[pos + 1]), 1); } else{ cin >> h; cout << get(1, 1, 1e6, h) << endl; } } }

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:65:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("game.in", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
game.cpp:66:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("game.out", "w", stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...