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

哪里错了。...

Posted by direfire at 2006-10-21 00:50:06 on Problem 1182
#include <iostream> 
#include <sstream> 
#include <string> 
#include <vector> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <cstdio> 
#include <cstdlib> 
#include <cmath>
#include <math.h>
#include <string.h>
#include <stdlib.h>
using namespace std; 

#define REP(i, n) for(int i = 0; i<(n); i++) 
#define abs(a) ((a) >= 0 ? (a) : -(a)) 
#define inf 999999999 
typedef vector<int> VI; 
typedef vector<string> VS; 
typedef long long i64; 
typedef unsigned long long u64;

int n, k;
int main()
{
	cin>>n>>k;
	int res = 0;
	int v[50002];
	memset(v, 0, sizeof(v));
	for (int i = 0; i < k; i++)
	{
		int t, a, b;
//		cin>>t>>a>>b;
		scanf("%d%d%d", &t, &a, &b);
		if (a>n || b >n) res++;
		else {
			if (t==1) {
				if (v[a]==0 && v[b]==0) v[a] = v[b] = 1;
				else if (v[a]==0 && v[b]!=0) v[a] = v[b];
				else if (v[a]!=0 && v[b]==0) v[b] = v[a];
				else if (v[a]!=0 && v[b]!=0 && v[a] != v[b]) res++;
				else ;	
			}
			if (t==2) {
				if (v[a] == 0 && v[b] == 0) {v[a]=2; v[b]=1;}
				else if (v[a] != 0 && v[b] == 0) {
					if (v[a] == 1) v[b] = 3;
					else v[b] = v[a]-1;	
				}
				else if (v[a] == 0 && v[b] != 0) {
					if (v[b] == 3) v[a] = 1;
					else v[a] = v[b]+1;	
				}
				else if (v[a]!=0 && v[b]!=0) {
					if (v[a] == 1 && v[b] != 3) res++;
					else if(v[a] == 2 && v[b] !=1) res++;
					else if(v[a] == 3 && v[b] !=2) res++;	
				}	
			}	
		}	
	}
	printf("%d\n", res);
}

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