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

感觉就是POJ有病啊,这题那WA了

Posted by MDK at 2011-07-21 19:26:03 on Problem 2155
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;

#define FOPEN freopen("d:\\1.txt","r",stdin)
//#define lowbit(x) x & -x
int n;
int num[1005][1005];
int lowbit(int x){
    return x&(-x);
}

void setn(int a,int b)
{
    int tmp = a;
    while(b <= n)
    {
        a = tmp;
        while(a <= n)
        {
            num[a][b] ++ ;
            a += lowbit(a);
        }
        b += lowbit(b);
    }
}
int get(int x,int y)
{
    int s = 0;
    int tmp = x;
    while(y>0)
    {
        x = tmp;
        while(x>0)
        {
            s += num[x][y];
            x -= lowbit(x);
        }
        y -= lowbit(y);
    }
    return s;
}
int main()
{
    FOPEN;
    int ces;
    int t,a,b,c,d;
    cin>>ces;
    while(ces--)
    {
        memset(num,0,sizeof(num));
        cin>>n>>t;
        n++;
        for(int i=0;i<t;i++)
        {
            char ctmp;
            cin>>ctmp;
            if(ctmp == 'C')
            {
                cin>>a>>b>>c>>d;
                setn(a,b);
                setn(c+1,b);
                setn(a,d+1);
                setn(c+1,b+1);
            }
            else
            {
                cin>>a>>b;
                int ss = get(a,b);
                cout<<ss%2<<endl;
            }
        }
        if(ces) 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