• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 16,comments - 0,trackbacks - 0
            樹狀數組,inc(x,y)表示對[x-n][y-n]的區域執行一次反轉操作,這樣,getsum(x,y)將總會包含對[x][y]的操作,即為[x][y]的反轉總次數,根據奇偶性判斷當前狀態。
            #?include?<stdio.h>
            #?include?
            <string.h>

            #?define?N?
            1005

            int?n,?c[N][N];
            void?clr(int?nn)
            {
            ????????????????
            int?i;
            ????????????????
            for?(i?=?1;?i?<=?nn;?++i)
            ????????????????????????????????memset(c[i]
            +1,?0,?sizeof(c[0][0])*nn);
            }
            /******************************************************************/
            void?inc(int?x,?int?y)
            {
            ????????????????
            int?t;
            ????????????????
            while?(x?<=?n)
            ????????????????{
            ????????????????????????????????t?
            =?y;
            ????????????????????????????????
            while?(t?<=?n)?++?c[x][t],?t?+=?t&(-t);//?printf("%d\n",?t);
            ????????????????????????????????x?+=?x&(-x);
            ????????????????}
            }
            int?getsum(int?x,?int?y)
            {
            ????????????????
            int?t,?ret?=?0;
            ????????????????
            while?(x?>?0)
            ????????????????{
            ????????????????????????????????t?
            =?y;
            ????????????????????????????????
            while?(t?>?0)?ret?+=?c[x][t],?t?-=?t&(-t);//?printf("%d\n",?t);
            ????????????????????????????????x?-=?x&(-x);
            ????????????????}
            ????????????????
            return?ret;
            }
            /******************************************************************/
            int?main()
            {
            ????????????????
            char?ins[3];
            ????????????????
            int?X,?T,?x0,?y0,?x1,?y1;
            ????????????????scanf(
            "%d",?&X);
            ????????????????
            while?(X--)
            ????????????????{
            ????????????????????????????????scanf(
            "%d%d",?&n,?&T),?clr(n);
            ????????????????????????????????
            while?(T--)
            ????????????????????????????????{
            ????????????????????????????????????????????????scanf(
            "%s%d%d",?ins,?&x0,?&y0);
            ????????????????????????????????????????????????
            switch(ins[0])
            ????????????????????????????????????????????????{
            ????????????????????????????????????????????????????????????????
            case?'C':
            ????????????????????????????????????????????????????????????????{
            ????????????????????????????????????????????????????????????????????????????????scanf(
            "%d%d",?&x1,?&y1);
            ????????????????????????????????????????????????????????????????????????????????inc(x0,?y0);
            ????????????????????????????????????????????????????????????????????????????????inc(x0,?y1
            +1);
            ????????????????????????????????????????????????????????????????????????????????inc(x1
            +1,?y0);
            ????????????????????????????????????????????????????????????????????????????????inc(x1
            +1,?y1+1);
            ????????????????????????????????????????????????????????????????????????????????
            break;
            ????????????????????????????????????????????????????????????????}
            ????????????????????????????????????????????????????????????????
            case?'Q':?puts((getsum(x0,?y0)&0x1)???"1":"0");?break;
            ????????????????????????????????????????????????}
            ????????????????????????????????}
            ????????????????????????????????
            if?(X)?putchar('\n');
            ????????????????}

            ????????????????
            return?0;
            }

            posted on 2012-09-02 17:29 yajunw 閱讀(158) 評論(0)  編輯 收藏 引用
            亚洲欧美日韩中文久久| 久久婷婷国产综合精品| 精品免费久久久久国产一区| 日韩一区二区久久久久久| 久久精品国产亚洲Aⅴ香蕉 | 久久99国产综合精品免费| 国产精品久久久久久| 欧美一级久久久久久久大片| 国产精品免费看久久久| 99久久精品免费看国产| 精品久久久久久无码不卡| 国产精品美女久久久m| 亚洲人AV永久一区二区三区久久| 久久人妻少妇嫩草AV无码专区| 久久久精品日本一区二区三区| 久久精品无码专区免费东京热 | 97久久久久人妻精品专区| 欧美精品一区二区久久| 久久精品www| 成人国内精品久久久久影院| 精品伊人久久久| 久久精品亚洲乱码伦伦中文| 国产精品欧美久久久天天影视| 欧美日韩精品久久久久 | 人妻无码久久一区二区三区免费| 久久久黄片| 久久精品视屏| 久久久久国产| 久久久免费观成人影院| 香蕉久久一区二区不卡无毒影院 | 久久国产成人| 99re这里只有精品热久久| 男女久久久国产一区二区三区| 久久久久久久久66精品片| 要久久爱在线免费观看| 久久亚洲国产成人影院| 精品国产99久久久久久麻豆| 久久这里只有精品首页| 久久久无码精品亚洲日韩蜜臀浪潮| 久久中文字幕无码专区| 久久综合偷偷噜噜噜色|