1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 #define MAXN 110 5 #define MAXM 1010 6 struct node 7 { 8 int big[MAXM<<2]; 9 }; 10 node tree[MAXN<<2]; 11 inline int MAX(int x,int y) 12 { 13 return x>y?x:y; 14 } 15 void SubBuild(int t,int L,int R,int rt) 16 { 17 tree[t].big[rt]=-1; 18 if(L!=R) 19 { 20 int mid=(L+R)>>1; 21 SubBuild(t,L,mid,rt<<1); 22 SubBuild(t,mid+1,R,rt<<1|1); 23 } 24 } 25 void Build(int h1,int h2,int rt) 26 { 27 SubBuild(rt,0,1000,1); 28 if(h1!=h2) 29 { 30 int mid=(h1+h2)>>1; 31 Build(h1,mid,rt<<1); 32 Build(mid+1,h2,rt<<1|1); 33 } 34 } 35 void SubUpdate(int t,int x,int val,int L,int R,int rt) 36 { 37 if(L==R) 38 tree[t].big[rt]=MAX(tree[t].big[rt],val); 39 else 40 { 41 int mid=(L+R)>>1; 42 if(x<=mid) 43 SubUpdate(t,x,val,L,mid,rt<<1); 44 else 45 SubUpdate(t,x,val,mid+1,R,rt<<1|1); 46 tree[t].big[rt]=MAX(tree[t].big[rt<<1],tree[t].big[rt<<1|1]); 47 } 48 } 49 void Update(int x,int y,int val,int L,int R,int rt) 50 { 51 SubUpdate(rt,y,val,0,1000,1); 52 if(L!=R) 53 { 54 int mid=(L+R)>>1; 55 if(x<=mid) 56 Update(x,y,val,L,mid,rt<<1); 57 else 58 Update(x,y,val,mid+1,R,rt<<1|1); 59 } 60 } 61 int SubQuery(int t,int x,int y,int L,int R,int rt) 62 { 63 if(x<=L&&R<=y) 64 return tree[t].big[rt]; 65 int mid=(L+R)>>1,ans=-1; 66 if(x<=mid) 67 ans=MAX(ans,SubQuery(t,x,y,L,mid,rt<<1)); 68 if(y>mid) 69 ans=MAX(ans,SubQuery(t,x,y,mid+1,R,rt<<1|1)); 70 return ans; 71 } 72 int Query(int h1,int h2,int a1,int a2,int L,int R,int rt) 73 { 74 if(h1<=L&&R<=h2) 75 return SubQuery(rt,a1,a2,0,1000,1); 76 int mid=(L+R)>>1,ans=-1; 77 if(h1<=mid) 78 ans=MAX(ans,Query(h1,h2,a1,a2,L,mid,rt<<1)); 79 if(h2>mid) 80 ans=MAX(ans,Query(h1,h2,a1,a2,mid+1,R,rt<<1|1)); 81 return ans; 82 } 83 int main() 84 { 85 char ch; 86 int q,h1,h2,ans; 87 double a1,a2,val; 88 while(scanf("%d",&q),q) 89 { 90 Build(100,200,1); 91 while(q--) 92 { 93 scanf(" %c",&ch); 94 if(ch=='I') 95 { 96 scanf("%d%lf%lf",&h1,&a1,&val); 97 Update(h1,int(a1*10),int(val*10),100,200,1); 98 } 99 else 100 { 101 scanf("%d%d%lf%lf",&h1,&h2,&a1,&a2); 102 if(h1>h2) 103 swap(h1,h2); 104 if(a1>a2) 105 swap(a1,a2); 106 ans=Query(h1,h2,(int)(a1*10),(int)(a2*10),100,200,1); 107 if(ans<0) 108 puts("-1"); 109 else 110 printf("%.1lf\n",ans/10.0); 111 } 112 } 113 } 114 return 0; 115 }