Rezultati

Up. imeNalogaJezikRezultatČas oddaje
finalsolution-2018 Puzzle C 100/100OK 19. apr '18 @ 17:43

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 1,426 MiB 0,000 s OK
#2 10/10 1,422 MiB 0,000 s OK
#3 10/10 1,418 MiB 0,000 s OK
#4 10/10 1,336 MiB 0,000 s OK
#5 10/10 1,422 MiB 0,000 s OK
#6 10/10 1,426 MiB 0,005 s OK
#7 10/10 1,422 MiB 0,005 s OK
#8 10/10 1,336 MiB 0,000 s OK
#9 10/10 1,426 MiB 0,000 s OK
#10 10/10 1,336 MiB 0,000 s OK

Ocenjevani program (puzzle.c):
#include <stdio.h>

static char P[9][8];
static char S[10][10] = {
    "         ",
    "         ",
    "         ",
    "         ",
    "         ",
    "         ",
    "         ",
    "         ",
    "         ",
    "         ",
};

static int recurse(int pos, int used) {
    if (pos >= 9) return 1;
    int i = 0, tx = 3 * (pos % 3), ty = 3 * (pos / 3) + 1;
    for (; i < 9; i++) {
        if (used & (1 << i)) continue;
        int j = 0;
        for (; j < 4; j++) {
            if (S[ty-1][tx+1] > 32 && (S[ty-1][tx+1] ^ P[i][j]) != 0x20) continue;
            if (S[ty+1][tx-1] > 32 && (S[ty+1][tx-1] ^ P[i][j+3]) != 0x20) continue;
            S[ty][tx+1] = P[i][j];
            S[ty+1][tx+2] = P[i][j+1];
            S[ty+2][tx+1] = P[i][j+2];
            S[ty+1][tx] = P[i][j+3];
            if (recurse(pos + 1, used | (1 << i))) return 1;
        }
    }
    return 0;
}

int main() {
    int i = 0;
    for (; i < 9; i++) {
        scanf("%s", P[i]);
        P[i][4] = P[i][0];
        P[i][5] = P[i][1];
        P[i][6] = P[i][2];
    }
    recurse(0, 0);
    for (i = 0; i < 9; i++) printf("%s\n", S[i+1]);
    return 0;
}