Submission #165194

#TimeUsernameProblemLanguageResultExecution timeMemory
165194theStaticMindDeda (COCI17_deda)C++14
20 / 140
414 ms37036 KiB
#include<bits/stdc++.h> #define mp make_pair #define pb push_back #define ii pair<int,int> #define all(x) (x).begin(),(x).end() #define INF 100000000000000000 #define modulo 1000000007 #define mod 998244353 #define int long long int using namespace std; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("q.gir","r",stdin); // freopen("q.cik","w",stdout); int n,q,ind=0; cin>>n>>q; map<int,map<int,ii>> Q; vector<int>ans; for(int i=0;i<q;i++){ char c; int x,y; cin>>c>>x>>y; if(c=='M')Q[x][i]={y,INF}; else Q[x][i]={y,ind++}; } set<int>data; ans.resize(ind,-1); for(map<int,map<int,ii>>::iterator itr=Q.begin();itr!=Q.end();itr++){ for(map<int,ii>::iterator it=itr->second.begin();it!=itr->second.end();it++){ if(it->second.second==INF){ data.insert(it->second.first); } else{ set<int>::iterator a=data.lower_bound(it->second.first); if(a!=data.end())ans[it->second.second]=*a; } } } for(int i=0;i<ind;i++)cout<<ans[i]<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...