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 gdczcpy at 2010-05-31 19:26:58 on Problem 2470
In Reply To:这道题目是什么意思。。。。谁能帮忙解释一下题意 Posted by:yf at 2006-07-11 19:01:51
> 真是郁闷,题意都没读懂!
给你代码你一看就懂什么意思了
//Ambiguous permutations

#include <stdio.h>

int p[100002];
int inverse[100001];
int init_pos[100001];
int n;

void deal()
{
	int i;
	for (i = 0; i < n; i++)
	{
		inverse[i] = init_pos[i + 1];
		if (inverse[i] != p[i])
		{
			printf("not ambiguous\n");
			return;
		}
	}
	printf("ambiguous\n");
}

void input()
{
	scanf("%d", &n);
	while (n)
	{
		int i;
		for (i = 0; i < n; i++)
		{
			scanf("%d", &p[i]);
			init_pos[p[i]] = i + 1;
		}
		deal();
		scanf("%d", &n);
	}
}

int main()
{
	input();
	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