Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:大牛看一下,怎么老是wrong answer呢?用了位运算,自己电脑上是可以。。。。。

Posted by zh1 at 2013-02-28 17:35:13 on Problem 2155
In Reply To:大牛看一下,怎么老是wrong answer呢?用了位运算,自己电脑上是可以。。。。。 Posted by:cer at 2009-04-11 14:24:54
> 要是把所用的变量都改成__int64 就tle ,真是晕死,怎么改进呢?可以讲一下树状数组吗?怎么实现?谢谢!!!
> 
> #include <iostream>
> #include <cstring>
> using namespace std;
> unsigned __int64 a[15626],x;
> 
> int main()
> {
>     int test_case,r,inner_case,x1,x2,y1,y2,l,u;
>     long start,end,lstart,uend,tmp;
>     char op[2];
>     scanf("%d",&test_case);
>     while(test_case--){
>             scanf("%d%d",&r,&inner_case);
>             tmp=(r*r)>>6;
>             memset(a,0,tmp+1);
>             while(inner_case--){
>                      scanf("%s",op);
>                      if(op[0]=='C'){
>                            scanf("%d%d%d%d",&x1,&y1,&x2,&y2);  
>                            for(int i=x1;i<=x2;i++){
>                                    x=0;
>                                    x=~x;
>                                    start=(i-1)*r+y1;
>                                    end=(i-1)*r+y2;
>                                    l=((start-1)>>6);
>                                    u=((end-1)>>6);
>                                    tmp=start&63;
>                                    lstart=(tmp==0)?64:tmp;
>                                    tmp=end&63;
>                                    uend=(tmp==0)?64:tmp;
>                                    if(l==u){
>                                        x=(x<<(63-uend+lstart));
>                                        x=(x>>(64-uend));
>                                        a[l]=a[l]^x;
>                                    }
>                                    else{
>                                         x=x<<(lstart-1);
>                                         a[l]=a[l]^x;
>                                         x=0;
>                                         x=~x;
>                                         x=x>>(64-uend);
>                                         a[u]=a[u]^x;
>                                         for(int j=l+1;j<=u-1;j++){
>                                                 a[j]=~a[j];
>                                         }
>                                    }
>                            }
>                      }
>                      else{
>                           scanf("%d%d",&x1,&y1);
>                           y2=(x1-1)*r+y1;
>                           l=(y2-1)>>6;
>                           tmp=y2&63;
>                           u=tmp==0?64:tmp;
>                           x=1;
>                           x=x<<(u-1);
>                           printf("%d\n",((a[l]&x)!=0));
>                      }
>             }
>             printf("\n");
>     }
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator