55pts求助,悬赏一关
查看原帖
55pts求助,悬赏一关
550933
Tjaweiof楼主2023/11/27 20:57

RT

#include <bits/stdc++.h>
using namespace std;
int m, n, x, y, cnt[11];
char ans[3001][3001];
void make(int n, int x, int y){
	if (n > m){
		return;
	}
	ans[x][y] = 'o';
	int lx = x, ly = y, rx = x, ry = y;
	for (int i = 1; i <= cnt[n]; i++){
		lx++;
		ly--;
		rx++;
		ry++;
		ans[lx][ly] = '/';
		ans[rx][ry] = '\\';
	}
	lx++;
	ly--;
	rx++;
	ry++;
	make(n + 1, lx, ly);
	make(n + 1, rx, ry);
	return;
}
void change(int r, int c){
	for (int i = r - cnt[x - 1]; i <= r + cnt[x - 1]; i++){
		for (int j = c - cnt[x - 1]; j <= c + cnt[x - 1]; j++){
			ans[i][j] = 32;
		}
	}
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(ans, 32, sizeof ans);
	cin >> m >> n;
	cnt[m - 1] = 1;
	cnt[m - 2] = 2;
	for (int i = m - 3; i >= 0; i--){
		cnt[i] = (cnt[i + 1] << 1) + 1;
	}
	make(1, 1, cnt[0]);
	for (int i = 1; i <= n; i++){
		cin >> x >> y;
		int nx = 1;
		for (int j = 1; j <= x - 1; j++){
			nx += cnt[j] + 1;
		}
		change(nx, (y - 1) * ((cnt[x - 1] << 1) + 2) + cnt[x - 1]);
	}
	for (int i = 1; i <= cnt[0] + 1; i++){
		for (int j = 0; j <= cnt[0] + i - 1; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

2023/11/27 20:57
加载中...