Submission #268596

#TimeUsernameProblemLanguageResultExecution timeMemory
268596stefantagaQueue (CEOI06_queue)C++14
0 / 100
1096 ms2092 KiB
#include <bits/stdc++.h> using namespace std; map <int,int> m; map <int,pair<int,int> > m1; int nr,i,n,q; struct wow { int x,y; }v[50005]; struct query { int poz;char tip; }query[50005]; int q1; pair <int,int> valori[50005]; int pozitie (int x) { int sol=0,i; if (m1.find(x)!=m1.end()) { for (i=m1[x].second+1;i<=q1;i++) { if (valori[i].first<=m1[x].first&&m1[x].first<=valori[i].second) { sol++; } } m1[x].first+=sol; return m1[x].first; } for (i=1;i<=q1;i++) { if (valori[i].first<=x&&x<=valori[i].second) { sol++; } } return x+sol; } int pozitie1; int main() { ios_base :: sync_with_stdio(false); cin.tie(0); #ifdef HOME ifstream cin("queue.in"); ofstream cout("queue.out"); #endif // HOME cin>>n; for (i=1;i<=n;i++) { cin>>v[i].x>>v[i].y; pozitie1=pozitie(v[i].y); valori[++q1]={pozitie1,pozitie(v[i].x)-1}; m1[v[i].x]={pozitie1,i}; } cin>>q; for (i=1;i<=q;i++) { cin>>query[i].tip>>query[i].poz; if (query[i].tip=='P') { cout<<pozitie(query[i].poz)<<'\n'; } else { cout<<"-1"<<'\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...