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:RE了很多次 不知道是什么原因 大牛们帮我找一下吧 谢谢谢

Posted by wxyfreedom at 2011-08-16 13:59:36 on Problem 2777
In Reply To:RE了很多次 不知道是什么原因 大牛们帮我找一下吧 谢谢谢 Posted by:Binbin1212 at 2011-08-06 10:53:45
> #pragma warning (disable:4786)
> #include <iostream>
> #include <stdio.h>
> #include <string>
> #include <string.h>
> #include <stdlib.h>
> #include <algorithm>
> #include <vector>
> #include <map>
> #include <math.h>
> #include <queue>
> #include <stack>
> #include <list>
> #include <deque>
> #include <set>
> #include <numeric>
> #include <functional>
> #include <ctype.h>
> #include <utility>
> #include <cassert>
> #include <time.h>
> using namespace std;
> 
> #define Maxn 1000001
> 
> map<int,int>c;
> 
> int ans;
> 
> struct node
> {
> int l,r;
> int color[32];
> int sum;
> int cover;
> node()
> {
> memset(color,0,sizeof(color));
> }
> }T[Maxn*4];
> 
> void Build(int l,int r,int root)
> {
> T[root].l=l;
> T[root].r=r;
> T[root].cover=1;
> T[root].color[1]=1;
> if(l==r)
> {
> 
> return;
> }
> if(l<r)
> {int Mid=(l+r)/2;
> Build(l,Mid,root*2);
> Build(Mid+1,r,root*2+1);
> }
> }
> 
> 
> 
> void add(int l,int r,int w,int root)
> {
> int i;
> if(T[root].cover)
> {
> 
> 	int ww;
> 	for(i=1;i<32;i++)
> 		if(T[root].color[i])
> 		{
> 			ww=i;
> 			break;
> 		}
> 	for(i=1;i<32;i++)
> 	{
> 		T[root*2].color[i]=0;
> 		T[root*2+1].color[i]=0;
> 	}
> 	T[root*2].color[ww]=1;
> 	T[root*2+1].color[ww]=1;
> 	T[root*2].cover=1;
> 	T[root*2+1].cover=1;
> }
> if(T[root].l==l&&T[root].r==r)
> {
> for(i=1;i<32;i++)
> if(T[root].color[i])
> T[root].color[i]=0;
> T[root].color[w]=1;
> T[root].cover=1;
> return;
> }
> 
> if(T[root].l<T[root].r)
> {int Mid=(T[root].l+T[root].r)/2;
> if(r<=Mid)
> add(l,r,w,root*2);
> else if(l>Mid)
> add(l,r,w,root*2+1);
> else
> {
> add(l,Mid,w,root*2);
> add(Mid+1,r,w,root*2+1);
> }}
> int t=0;
> for(i=1;i<32;i++)
> {
> T[root].color[i]=0;
> if(T[root*2].color[i]||T[root*2+1].color[i])
> {
> T[root].color[i]=1;
> t++;
> }
> }
> if(t==1&&T[root*2].cover&&T[root*2+1].cover)
> T[root].cover=1;
> else
> T[root].cover=0;
> }
> 
> void querysum(int l,int r,int root)
> {
> int i;
> if(T[root].cover)
> {
> for(i=1;i<32;i++)
> if(T[root].color[i]&&!c[i])
> {
> ans++;
> c[i]=1;
> }
> return;
> }
> if(T[root].l==l&&T[root].r==r)
> {
> for(i=1;i<32;i++)
> {
> // printf("clolor=%d,c[i]=%d\n",T[root].color[i],c[i]);
> if(T[root].color[i]&&!c[i])
> {
> c[i]=1;
> ans++;
> }}
> return;
> }
> if(T[root].l<T[root].r)
> {int Mid=(T[root].l+T[root].r)/2;
> if(r<=Mid)
> querysum(l,r,root*2);
> else if(l>Mid)
> querysum(l,r,root*2+1);
> else
> {
> querysum(l,Mid,root*2);
> querysum(Mid+1,r,root*2+1);
> }}
> }
> 
> int main()
> {
> int n,m,o,i,x,y,z;
> char s[2];
> scanf("%d%d%d",&n,&m,&o);
> Build(1,n,1);
> while(o--)
> {
> scanf("%s",s);
> if(s[0]=='P')
> {
> scanf("%d%d",&x,&y);
> if(x>y)
> {
> i=x;
> x=y;
> y=i;
> }
> ans=0;
> c.clear();
> querysum(x,y,1);
> //printf("%d %d %d %d\n",T[1].color[9],T[1].color[10],T[1].color[9],T[1].color[10]);
> //printf("%d\n",T[7].cover);
> printf("%d\n",ans);
> }
> else if(s[0]=='C')
> {
> scanf("%d%d%d",&x,&y,&z);
> if(x>y)
> {
> i=x;
> x=y;
> y=i;
> }
> add(x,y,z,1);
> // printf("%d\n",T[1].color[2]);
> }
> }
> return 0;
> }

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