hwangnk1004 / Algorithm

0 stars 0 forks source link

StepByStep #모호한 순열 #290

Open hwangnk1004 opened 4 years ago

hwangnk1004 commented 4 years ago

import java.util.Scanner;

public class Main { public static void main(String args[]) {

    Scanner scanner = new Scanner(System.in);

    int n = scanner.nextInt();
    String str = "ambiguous";
    int arr[] = new int[n + 1];

    for (int i = 1; i <= n; i++) {
        arr[i] = scanner.nextInt();

    }

    for (int i = 1; i < n; i++) {
        if (arr[arr[i]] != i) {
            str = "not ambiguous";
            break;
        }
    }
    System.out.println(str);
}

}