add test data
This commit is contained in:
74
test/testcases/magic.c
Normal file
74
test/testcases/magic.c
Normal file
@ -0,0 +1,74 @@
|
||||
#include "io.inc"
|
||||
int make[3][3];
|
||||
int color[10];
|
||||
int count[1];
|
||||
int i;
|
||||
int j;
|
||||
|
||||
void origin(int N) {
|
||||
for (i = 0; i < N; i++) {
|
||||
for (j = 0; j < N; j++)
|
||||
make[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void search(int x, int y, int z) {
|
||||
int s;
|
||||
int i;
|
||||
int j;
|
||||
if ((y > 0 || y < 0) || x == 0 ||
|
||||
make[x - 1][0] + make[x - 1][1] + make[x - 1][2] == 15) {
|
||||
if (x == 2 && y == 2) {
|
||||
make[2][2] = 45 - z;
|
||||
s = make[0][0] + make[0][1] + make[0][2];
|
||||
if (make[1][0] + make[1][1] + make[1][2] == s &&
|
||||
make[2][0] + make[2][1] + make[2][2] == s &&
|
||||
make[0][0] + make[1][0] + make[2][0] == s &&
|
||||
make[0][1] + make[1][1] + make[2][1] == s &&
|
||||
make[0][2] + make[1][2] + make[2][2] == s &&
|
||||
make[0][0] + make[1][1] + make[2][2] == s &&
|
||||
make[2][0] + make[1][1] + make[0][2] == s) {
|
||||
count[0] = count[0] + 1;
|
||||
for (i = 0; i <= 2; i++) {
|
||||
for (j = 0; j <= 2; j++) {
|
||||
printInt(make[i][j]);
|
||||
printStr(" ");
|
||||
}
|
||||
printStr("\n");
|
||||
}
|
||||
printStr("\n");
|
||||
}
|
||||
} else {
|
||||
if (y == 2) {
|
||||
make[x][y] = 15 - make[x][0] - make[x][1];
|
||||
if (make[x][y] > 0 && make[x][y] < 10 && color[make[x][y]] == 0) {
|
||||
color[make[x][y]] = 1;
|
||||
if (y == 2)
|
||||
search(x + 1, 0, z + make[x][y]);
|
||||
else
|
||||
search(x, y + 1, z + make[x][y]);
|
||||
color[make[x][y]] = 0;
|
||||
}
|
||||
} else {
|
||||
for (i = 1; i <= 9; i++) {
|
||||
if (color[i] == 0) {
|
||||
color[i] = 1;
|
||||
make[x][y] = i;
|
||||
if (y == 2)
|
||||
search(x + 1, 0, z + i);
|
||||
else
|
||||
search(x, y + 1, z + i);
|
||||
make[x][y] = 0;
|
||||
color[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
origin(3);
|
||||
search(0, 0, 0);
|
||||
printInt(count[0]);
|
||||
return judgeResult % Mod; // 106
|
||||
}
|
Reference in New Issue
Block a user