Question: give you n dice, place them into a tower, and the numbers of the adjacent dice are different. What you see is only the numbers on the top and on both sides. The numbers on the top and on both sides can be uniquely identified.
Solution: since it is necessary to be unique and the number at the top (assuming z) is determined, it is impossible to uniquely determine all the numbers, the number of the sides of one or more dice below is Z or 7-z. In this way, the problem can be solved. The Code is as follows:
import java.io.BufferedInputStream;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int len = 101; int[] x = new int[len]; int[] y = new int[len]; int z = -1, n = -1; boolean flag; while (cin.hasNext()) { n = cin.nextInt(); z = cin.nextInt(); flag = true; for (int i = 0; i < n; i++) { x[i] = cin.nextInt(); y[i] = cin.nextInt(); if (flag && (0 != i)) { if (isTrue(x[i], z) || isTrue(y[i], z)) { flag = false; } } } if (flag) { System.out.printf("YES"); } else { System.out.printf("NO"); } } cin.close(); } private static boolean isTrue(int i, int z) { if (i == z || i + z == 7) { return true; } return false; }}
I understood it wrong last night and kept wrong. Alas, English is too bad !! Come on !!