Submission #211406

#TimeUsernameProblemLanguageResultExecution timeMemory
211406ahzongDeda (COCI17_deda)C++17
20 / 140
465 ms8252 KiB
/*input 3 4 M 10 3 M 5 1 D 20 2 D 5 1 */ #include <bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define watch(x) cout << (#x) << " is " << (x) << endl #define debug cout << "hi" << endl using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const int MOD = 1e9 + 7; const int INF32 = 1<<30; const ll INF64 = 1LL<<60; vector<int> t; int query(int v, int tl, int tr, int l, int r, int x) { if(tl > r || tr < l) return -2; if(l <= tl && tr <= r) { if(t[v] > x) return -2; while(tl != tr) { int tm = (tl + tr)/2; if(t[2 * v] <= x) { v = 2 * v; tr = tm; } else { v = 2 * v + 1; tl = tm + 1; } } return tl; } int tm = (tl + tr)/2; int res = query(2 * v, tl, tm, l, r, x); if(res != -2) return res; return query(2 * v + 1, tm + 1, tr, l, r, x); } void update(int v, int tl, int tr, int pos, int x) { if(tl == tr) t[v] = x; else { int tm = (tl + tr)/2; if(pos <= tm) update(2 * v, tl, tm, pos, x); else update(2 * v + 1, tm + 1, tr, pos, x); t[v] = min(t[2 * v], t[2 * v + 1]); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; cin >> n >> q; t.resize(4 * n); for(int i = 0; i < 4 * n; i++) t[i] = 100; while(q--) { char c; cin >> c; if(c == 'D') //query { int y, b; cin >> y >> b; b--; int res = query(1, 0, n - 1, b, n - 1, y); cout << query(1, 0, n - 1, b, n - 1, y) + 1 << endl; } else //update { int x, a; cin >> x >> a; a--; update(1, 0, n - 1, a, x); } } return 0; }

Compilation message (stderr)

deda.cpp: In function 'int main()':
deda.cpp:79:11: warning: unused variable 'res' [-Wunused-variable]
       int res = query(1, 0, n - 1, b, n - 1, y);
           ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...