@@ -0,0 +1,1139 @@
+import java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class LoveTriangle %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));%0A        System.out.println(run(reader));%0A    %7D%0A%0A    private static String run(BufferedReader reader) throws IOException %7B%0A        int amountOfPlanes = Integer.parseInt(reader.readLine());%0A        String%5B%5D planes = reader.readLine().split(%22 %22);%0A        Map%3CInteger, Integer%3E planePairs = new HashMap%3C%3E(amountOfPlanes * 2);%0A        for (int i = 0; i %3C amountOfPlanes; i++) %7B%0A            planePairs.put(i + 1, Integer.parseInt(planes%5Bi%5D));%0A        %7D%0A%0A        for (Map.Entry%3CInteger, Integer%3E entry : planePairs.entrySet()) %7B%0A            Integer first = entry.getKey();%0A            Integer second = entry.getValue();%0A            Integer third = planePairs.get(second);%0A            if (third != null && first.equals(planePairs.get(third))) %7B%0A                return %22YES%22;%0A            %7D%0A        %7D%0A        return %22NO%22;%0A    %7D%0A%7D%0A

Add LoveTriangle