1 #include 2 #include 3 #include 4 #define MAXN 2010 5 using namespace std; 6 struct Line 7 { 8 int left,right,color; 9 }; 10 Line p[MAXN]; 11 int x[MAXN<<2],tree[MAXN<<4]; 12 bool vis[MAXN<<2]; 13 inline void PushDown(int rt) 14 { 15 if(tree[rt]!=-1) 16 { 17 tree[rt<<1]=tree[rt<<1|1]=tree[rt]; 18 tree[rt]=-1; 19 } 20 } 21 void Build(int L,int R,int rt) 22 { 23 if(L==R) 24 tree[rt]=0; 25 else 26 { 27 int mid=(L+R)>>1; 28 tree[rt]=-1; 29 Build(L,mid,rt<<1); 30 Build(mid+1,R,rt<<1|1); 31 } 32 } 33 void Update(int st,int en,int val,int L,int R,int rt) 34 { 35 if(st<=L&&R<=en) 36 tree[rt]=val; 37 else 38 { 39 int mid=(L+R)>>1; 40 PushDown(rt); 41 if(mid>=st) 42 Update(st,en,val,L,mid,rt<<1); 43 if(en>mid) 44 Update(st,en,val,mid+1,R,rt<<1|1); 45 } 46 } 47 void Query(int L,int R,int rt) 48 { 49 if(tree[rt]==1) 50 { 51 for(int i=L;i<=R;i++) 52 vis[i]=true; 53 } 54 else if(tree[rt]==-1) 55 { 56 int mid=(L+R)>>1; 57 Query(L,mid,rt<<1); 58 Query(mid+1,R,rt<<1|1); 59 } 60 } 61 int main() 62 { 63 char ch; 64 int n,m,k,i,j,st,en; 65 while(~scanf("%d",&n)) 66 { 67 if(n==0) 68 { 69 puts("Oh, my god"); 70 continue; 71 } 72 for(k=i=0;i p[i].right) 76 swap(p[i].left,p[i].right); 77 if(ch=='b') 78 p[i].color=0; 79 else 80 p[i].color=1; 81 x[k++]=p[i].left; 82 x[k++]=p[i].right; 83 } 84 sort(x,x+k); 85 k=unique(x,x+k)-x; 86 for(i=k-1;i>0;i--) 87 { 88 if(x[i]!=x[i-1]+1) 89 x[k++]=x[i-1]+1; 90 } 91 sort(x,x+k); 92 Build(0,k-1,1); 93 for(i=0;i