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

cin 和 scanf 花费的时间区别很大

Posted by pb03005073 at 2006-12-21 11:28:29 on Problem 2470
#include <iostream>
#include <cstdio>
using namespace std;

int solver(int num[],int n)
{
	for(int i=1;i<=n;i++)
		if(num[num[i]]!=i)
			return 0;

	return 1;
}

void main()
{
	int n;
	int num[100001];
	cin>>n;

	while(n)
	{
		for(int i=1;i<=n;i++)
			scanf("%d",&num[i]);//过
                       //cin>>num[i];//不过   
		 if(solver(num,n))
			 cout<<"ambiguous"<<endl;
		 else 
			 cout<<"not ambiguous"<<endl;
		 cin>>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