hiho week 153 register

Ended

Participants:259

Verdict:Accepted
Score:100 / 100
Submitted:2017-06-09 19:32:03

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<cstdio>
struct node{
    int t,p;
}q1[500005],q2[500005];int head1=0,tail1=0,head2=0,tail2=0;
int recent;
int main(){
    int n;scanf("%d",&n);
    char buf[10];
    int x,y;
    while(n--){
        scanf("%s",buf);
        if(buf[0]=='P'){
            scanf("%d%d",&x,&y);recent=y;
            while(head1!=tail1&&q1[tail1-1].p<y)tail1--;
            q1[tail1].t=x;q1[tail1].p=y;tail1++;
            while(head2!=tail2&&q2[tail2-1].p>y)tail2--;
            q2[tail2].t=x;q2[tail2].p=y;tail2++;
        }else if(buf[0]=='Q'){
            printf("%d %d %d\n",q1[head1].p,q2[head2].p,recent);
        }else{
            scanf("%d",&x);
            while(head1!=tail1&&q1[head1].t<=x)head1++;
            while(head2!=tail2&&q2[head2].t<=x)head2++;
        }
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX