Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

ambiguous permutation

$
0
0

import java.io.*; import java.util.Scanner;

class test1 {

public static void main(String[] args)throws IOException {

    int count=1;

    BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));

    while(true)
    {

        if(Integer.parseInt(br.readLine()) ==0)
        {
            break;
        }
        String str = br.readLine();
        String a[] =  str.split(" ");

     for(int i=0;i<a.length;i++)   
     {



    if(Integer.parseInt(a[Integer.parseInt(a[i])-1])==i+1)
    {
        count=1;
    }
         else
    {
        count=0;
    }

     }

     if(count==1)
     {
         System.out.println("ambiguous");
     }
     else
     {
         System.out.println("not ambiguous");
     }

    }

}

}

its running fine in my netbeans but getting wrong ans here ???


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>