제출 #373376

#제출 시각아이디문제언어결과실행 시간메모리
373376Atill83Deda (COCI17_deda)C++14
100 / 140
1089 ms8172 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define endl '\n' using namespace std; const long long INF = (long long) 1e18; const int mod = (int) 1e9+7; const int MAXN = (int) 2e5+5; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; int n, q; int t[4*MAXN]; void upd(int v, int tl, int tr, int pos, int coc){ if(tl == tr){ t[v] = coc; }else{ int tm = (tl + tr) / 2; if(pos <= tm) upd(2*v, tl, tm, pos, coc); else upd(2*v + 1, tm + 1, tr, pos, coc); t[v] = min(t[2*v], t[2*v + 1]); } } int que(int v, int tl, int tr, int l, int r){ if(l > r){ return mod; }else if(tl == l && tr == r){ return t[v]; }else { int tm = (tl + tr) / 2; return min(que(2*v, tl, tm, l, min(tm, r)), que(2*v + 1, tm + 1, tr, max(tm + 1, l), r)); } } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); #ifdef Local freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin); freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout); #endif cin>>n>>q; memset(t, 0x7f, sizeof(t)); upd(1, 1, n + 1, n + 1, 0); set<pii> st; while(q--){ char ty; cin>>ty; if(ty == 'D'){ int y, b; cin>>y>>b; int l = b, r = n + 1; while(l < r){ int m = (l + r) / 2; if(que(1, 1, n + 1, b, m) <= y){ r = m; }else{ l = m + 1; } } cout<<(l >= n + 1 ? -1 : l )<<endl; }else{ int x, a; cin>>x>>a; upd(1, 1, n + 1, a, x); } } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...