#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
14 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
115 ms |
1120 KB |
Output isn't correct |
6 |
Incorrect |
851 ms |
1608 KB |
Output isn't correct |
7 |
Execution timed out |
1047 ms |
1400 KB |
Time limit exceeded |
8 |
Incorrect |
733 ms |
2092 KB |
Output isn't correct |
9 |
Execution timed out |
1085 ms |
1476 KB |
Time limit exceeded |
10 |
Execution timed out |
1083 ms |
1264 KB |
Time limit exceeded |
11 |
Execution timed out |
1059 ms |
1204 KB |
Time limit exceeded |
12 |
Execution timed out |
1058 ms |
1192 KB |
Time limit exceeded |
13 |
Execution timed out |
1091 ms |
1332 KB |
Time limit exceeded |
14 |
Execution timed out |
1089 ms |
1364 KB |
Time limit exceeded |
15 |
Execution timed out |
1047 ms |
1272 KB |
Time limit exceeded |
16 |
Execution timed out |
1087 ms |
1400 KB |
Time limit exceeded |
17 |
Incorrect |
104 ms |
1144 KB |
Output isn't correct |
18 |
Execution timed out |
1085 ms |
888 KB |
Time limit exceeded |
19 |
Execution timed out |
1081 ms |
892 KB |
Time limit exceeded |
20 |
Execution timed out |
1087 ms |
1016 KB |
Time limit exceeded |
21 |
Execution timed out |
1035 ms |
1644 KB |
Time limit exceeded |
22 |
Execution timed out |
1079 ms |
1728 KB |
Time limit exceeded |
23 |
Execution timed out |
1084 ms |
1824 KB |
Time limit exceeded |
24 |
Execution timed out |
1096 ms |
1432 KB |
Time limit exceeded |
25 |
Execution timed out |
1094 ms |
1720 KB |
Time limit exceeded |