Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdbool.h>
- #define NMAX 101
- int sides[NMAX], n, p;
- bool used[NMAX][NMAX];
- bool isValid(int line, int col, int side) {
- if (side + line >= n || side + col >= n) {
- return false;
- }
- for (int i = line; i < line + side; i++) {
- for (int j = col; j < col + side; j++) {
- if (used[i][j]) {
- return false;
- }
- }
- }
- return true;
- }
- void setSquare(int line, int col, int side, bool val) {
- for (int i = line; i < line + side; i++) {
- for (int j = col; j < col + side; j++) {
- used[i][j] = val;
- }
- }
- }
- bool isSol() {
- bool ok = true;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- ok &= used[i][j];
- }
- }
- return ok;
- }
- void bktr(int top) {
- for (int i = 0; i < n; i++) {
- for (int line = 0; line < n; line++) {
- for (int col = 0; col < n; col++) {
- if (isValid(line, col, sides[i])) {
- setSquare(line, col, sides[i], true);
- if (isSol()) {
- } else {
- }
- }
- }
- }
- }
- }
- int main(void) {
- int n;
- scanf("%d", &n);
- for (int i = 0; i < n; i++) {
- scanf("%d", sides + i);
- }
- scanf("%d", &p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement