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:和你一样崩溃中

Posted by acmpeishuai at 2008-07-27 17:37:39 on Problem 3678
In Reply To:这题思路不是这样吗?我感觉没错啊.. Posted by:timeloop at 2008-07-27 17:17:51
#include<iostream>
using namespace std;
#include<fstream>

void shaixuan(int & m,int& n,int c,char op,int & x)
{
	if(op=='AND'&&c==1)
	{
		if(m==-1&&n==-1)
		{
			m=n=1; x=-1;
		}
		else if(m==0||n==0)
		{
			cout<<"NO"<<endl; exit(0);
		}
	}//-----------------------------------------------------------
	if(op=='OR'&&c==0)
	{
		if(m==-1&&n==-1)
		{
	     	m=n=0; x=-1;
		}
        else if(m==1||n==1)
		{
            cout<<"NO"<<endl; exit(0);
		}
	}//----------------------------------------------------------
	if(op=='XOR'&&c==0)
	{
        if(m==1&&n==0||m==0&&n==1)
		{
			cout<<"NO"<<endl; exit(0);
		}
		if(m==1&&n==-1)
		{
			n=1; x=-1;
		}
	    
		else if(m==0&&n==-1)
		{	
			n=0; x=-1;
		}
		
		else if(m==-1&&n==1)
		{
			m=1; x=-1;
		}
		
		else if(m==-1&&n==0)
		{	
			m=0; x=-1;
		}
		
		
	}
	if(op=='XOR'&&c==1)
	{
		if(m==1&&n==1||m==0&&n==0)
		{
			cout<<"NO"<<endl;
		}
		else if(m==1&&n==-1)
		{	n=0; x=-1;}
		else if(m==0&&n==-1)
		{  n=1;x=-1;}
        
		else if(m==-1&&n==1)
		{	m=0; x=-1;}
		else if(m==-1&&n==0)
		{  m=1;x=-1;}

	}
}

struct info
{
	int m;
	int n;
	int c;
	char op;
	int flag;
} ;


int main()
{
	ifstream fin("11.in");
	struct info edge[10000];
	int i;
	int x[1000];
	int n,m;  
	fin>>n>>m;
	for(i=0;i<m;i++)
	{
		fin>>edge[i].m>>edge[i].n>>edge[i].c>>edge[i].op;
		edge[i].flag =0;
        shaixuan ( x[edge[i].m] , x[edge[i].n] , edge[i].c ,edge[i].op ,edge[i].flag );
	}

    cout<<"YES"<<endl;
	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