日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2014 网选 广州赛区 hdu 5023 A Corrupt Mayor's Performance Art

發布時間:2025/3/8 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2014 网选 广州赛区 hdu 5023 A Corrupt Mayor's Performance Art 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 #define N 1000005 6 using namespace std; 7 8 int c[35]; 9 int tree[N*4];//正值表示該節點所管理的區間的顏色是純色,-1表示的是非純色 10 int n, m; 11 12 void buildT(int ld, int rd, int p){ 13 if(ld <= rd){ 14 tree[p] = 2;//初始每一個節點的顏色全部都是2 15 if(ld == rd) return; 16 int mid=(ld + rd)>>1; 17 buildT(ld, mid, p<<1); 18 buildT(mid+1, rd, p<<1|1); 19 } 20 } 21 22 void updateT(int ld, int rd, int a, int b, int col, int p){ 23 24 if(ld > rd) return ; 25 26 if(tree[p] == col) return ; 27 28 if(ld == a && rd == b){ 29 tree[p] = col; 30 return ; 31 } 32 int mid = (ld + rd)>>1; 33 34 if(tree[p] != -1){// p所管的區間之前是純色,現在不是純色了,向下更新其孩子節點的顏色為它的顏色 35 tree[p<<1] = tree[p<<1 | 1] = tree[p]; 36 tree[p] = -1; 37 } 38 39 if(a > mid) 40 updateT(mid+1, rd, a, b, col, p<<1 | 1); 41 else if(b <= mid) 42 updateT(ld, mid, a, b, col, p<<1); 43 else{ 44 updateT(ld, mid, a, mid, col, p<<1); 45 updateT(mid+1, rd, mid+1, b, col, p<<1 | 1); 46 } 47 } 48 49 int cnt; 50 51 void querryT(int ld, int rd, int a, int b, int p){ 52 if(ld>rd) return ; 53 54 if(tree[p] != -1){//一直找到純色的區間! 55 c[tree[p]]=1; 56 return ; 57 } 58 59 int mid = (ld+rd)>>1; 60 if(a > mid) 61 querryT(mid+1, rd, a, b, p<<1 | 1); 62 else if(b <= mid) 63 querryT(ld, mid, a, b, p<<1) ; 64 else{ 65 querryT(ld, mid, a, mid, p<<1); 66 querryT(mid+1, rd, mid+1, b, p<<1 | 1); 67 } 68 } 69 70 int main(){ 71 while(scanf("%d%d", &n, &m) && (n || m)){ 72 char ch[2]; 73 int a, b, k; 74 buildT(1, n, 1); 75 while(m--){ 76 scanf("%s", ch); 77 if(ch[0] == 'P'){ 78 scanf("%d%d%d", &a, &b, &k); 79 updateT(1, n, a, b, k, 1); 80 } 81 else{ 82 scanf("%d%d", &a, &b); 83 memset(c, 0, sizeof(c)); 84 querryT(1, n, a, b, 1); 85 int i; 86 for(i=1; i<=30; ++i) 87 if(c[i]){ 88 printf("%d", i); 89 break; 90 } 91 for(++i; i<=30; ++i) 92 if(c[i]) printf(" %d", i); 93 printf("\n"); 94 } 95 } 96 } 97 return 0; 98 }

?

轉載于:https://www.cnblogs.com/hujunzheng/p/3984149.html

總結

以上是生活随笔為你收集整理的2014 网选 广州赛区 hdu 5023 A Corrupt Mayor's Performance Art的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。