# 地毯填补问题

## 输入输出样例

### 输入样例 #1

3
3 3


### 输出样例 #1

5 5 1
2 2 4
1 1 4
1 4 3
4 1 2
4 4 1
2 7 3
1 5 4
1 8 3
3 6 3
4 8 1
7 2 2
5 1 4
6 3 2
8 1 2
8 4 1
7 7 1
6 6 1
5 8 3
8 5 2
8 8 1


## 说明

spj 报错：

1. $c$ 越界
2. $x,y$ 越界
3. $mp[x][y]$ 已被占用
4. $mp[x][y]$ 从未被使用

# 代码

/*
* @Author: crab-in-the-northeast
* @Date: 2020-04-29 10:48:00
*/
#include <iostream>
#include <cstdio>

void solve(int x1, int y1, int x2, int y2, int n) {
if(n == 1) return ;
if(x1 - x2 < (n >> 1)) {
if(y1 - y2 < (n >> 1)) {
std :: cout << (x2 + (n >> 1)) << ' ' << (y2 + (n >> 1)) << ' ' << 1 << std :: endl;
solve(x1, y1, x2, y2, (n >> 1));
solve(x2 + (n >> 1) - 1, y2 + (n >> 1), x2, y2 + (n >> 1), (n >> 1));
solve(x2 + (n >> 1), y2 + (n >> 1) - 1, x2 + (n >> 1), y2, (n >> 1));
solve(x2 + (n >> 1), y2 + (n >> 1), x2 + (n >> 1), y2 + (n >> 1), (n >> 1));
} else {
std :: cout << (x2 + (n >> 1)) << ' ' << (y2 + (n >> 1) - 1) << ' ' << 2 << std :: endl;
solve(x2 + (n >> 1) - 1, y2 + (n >> 1) - 1, x2, y2, (n >> 1));
solve(x1, y1, x2, y2 + (n >> 1), (n >> 1));
solve(x2 + (n >> 1), y2 + (n >> 1) - 1, x2 + (n >> 1), y2, (n >> 1));
solve(x2 + (n >> 1), y2 + (n >> 1), x2 + (n >> 1), y2 + (n >> 1), (n >> 1));
}
} else {
if(y1 - y2 < (n >> 1)) {
std :: cout << (x2 + (n >> 1) - 1) << ' ' << (y2 + (n >> 1)) << ' ' << 3 << std :: endl;
solve(x2 + (n >> 1) - 1, y2 + (n >> 1) - 1, x2, y2, (n >> 1));
solve(x2 + (n >> 1) - 1, y2 + (n >> 1), x2, y2 + (n >> 1), (n >> 1));
solve(x1, y1, x2 + (n >> 1), y2, (n >> 1));
solve(x2 + (n >> 1), y2 + (n >> 1), x2 + (n >> 1), y2 + (n >> 1), (n >> 1));
} else {
std :: cout << (x2 + (n >> 1) - 1) << ' ' << (y2 + (n >> 1) - 1) << ' ' << 4 << std :: endl;
solve(x2 + (n >> 1) - 1, y2 + (n >> 1) - 1, x2, y2, (n >> 1));
solve(x2 + (n >> 1) - 1, y2 + (n >> 1), x2, y2 + (n >> 1), (n >> 1));
solve(x2 + (n >> 1), y2 + (n >> 1) - 1, x2 + (n >> 1), y2, (n >> 1));
solve(x1, y1, x2 + (n >> 1), y2 + (n >> 1), (n >> 1));
}
}
}

int main() {
int k, x, y;
std :: cin >> k >> x >> y;
solve(x, y, 1, 1, 1 << k);
return 0;
}


# 评测记录

posted @ 2020-05-02 22:41  东北小蟹蟹  阅读(263)  评论(0编辑  收藏  举报