牛牛的DRB迷宫II(构造)
程序员文章站
2022-05-12 23:34:05
...
想不到的构造系列
题意:
- 给定一个数,要求构造一个
数据范围: rt
Tutorial:
首先看, 想到二进制拆分构造一个横坐标为30的矩阵, 对角线是2的k次方的方案数, 如果n在二进制表示的第i位上是1, 就要贡献到答案里:
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 7;
const ll maxn = 100;
char mat[35][35];
signed main() {
ll val;
cin >> val;
ll n = 32, m = 30;
_rep(i, 0, m) {
mat[1][i] = i >= 2 ? 'R' : 'B';
}
_rep(i, 2, 32) {
_rep(j, 0, i - 3) {
mat[i][j] = 'D';
}
mat[i][i - 2] = ((val >> (i - 2)) & 1) ? 'B' : 'R';
_rep(j, i-1, min(i, m)) {
mat[i][j] = 'B';
}
_rep(j, i + 1, m) {
mat[i][j] = 'R';
}
}
cout << n +1<< " " << m+1 << endl;
_rep(i, 1, n) {
cout << mat[i] << endl;
}
_rep(i, 1, 31) {
cout << 'R';
}
}