Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.4 kB
4
Indexable
import java.util.Scanner;

public class Main {
    static int[][] arr = new int[7][8];
    static int[][] check = new int[7][7];
    static int[][] visit = new int[7][8];
    static int result;

    public static void domino(int x, int y) {
        if (x == 7) {
            result++;
            return;
        }
        if (visit[x][y] == 0) {
            if (y < 7) {
                if (visit[x][y + 1] == 0) {
                    if (check[arr[x][y]][arr[x][y + 1]] == 0) {
                        check[arr[x][y]][arr[x][y + 1]] = 1;
                        check[arr[x][y + 1]][arr[x][y]] = 1;
                        visit[x][y] = 1;
                        visit[x][y + 1] = 1;
                        if (y + 1 < 7) domino(x, y + 1);
                        else domino(x + 1, 0);
                        check[arr[x][y]][arr[x][y + 1]] = 0;
                        check[arr[x][y + 1]][arr[x][y]] = 0;
                        visit[x][y] = 0;
                        visit[x][y + 1] = 0;
                    }
                }
            }
            if (x < 6) {
                if (visit[x + 1][y] == 0) {
                    if (check[arr[x][y]][arr[x + 1][y]] == 0) {
                        check[arr[x][y]][arr[x + 1][y]] = 1;
                        check[arr[x + 1][y]][arr[x][y]] = 1;
                        visit[x][y] = 1;
                        visit<x+