#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define RREP1(i, n) for (int i = (n); i >= 1; i--)
#define REP1(i, n) FOR(i, 1, n+1)
#define pii pair<int, int>
#define ppi pair<pii, int>
#define pip pair<int, pii>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define endl '\n'
#define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const ll maxn = 50;
const ll mod = 1e9+7;
const ll inf = (1ll<<60);
const int iinf = 1e9+5;
ll pw(ll x, ll p, ll m){
ll ret = 1;
while(p > 0){
if (p & 1){
ret *= x;
ret %= m;
}
x *= x;
x %= m;
p >>= 1;
}
return ret;
}
ll inv(ll x, ll m){
return pw(x, m-2, m);
}
int k;
char arr[maxn][maxn];
signed main(){
IOS();
vector<int> fib(89);
fib[0] = fib[1] = 1;
FOR(i, 2, 89){
fib[i] = fib[i-1] + fib[i-2];
}
cin>>k;
if (k <= 19){
int K = k;
K--;
REP(i, 6) REP(j, 6) arr[i][j] = '.';
REP1(i, 4) {
arr[5][i] = 'r';
arr[i][5] = 'd';
}
RREP1(i, 4){
for (int j = 5; j >= 2; j--){
if (j == 5) j = 1;
if (K > 0){
arr[i][j] = 'X';
if (j > 1 && i < 4) arr[i][j] = 'd';
K--;
}
if (j == 1) j = 5;
}
}
if (arr[1][1] == '.'){
arr[1][1] = 'd';
}
if (K >= 1){
arr[1][2] = 'X';
arr[1][3] = 'r';
arr[1][4] = (K==1?'r':'d');
}
cout<<5<<' '<<5<<endl;
REP1(i, 5){
REP1(j, 5){
cout<<arr[i][j];
}
cout<<endl;
}
return 0;
}
cout<<47<<' '<<47<<endl;
REP1(i, 45){
REP1(j, 45){
arr[i][j] = 'X';
}
REP1(j, i-1) arr[i][j] = 'r';
REP(j, max(44-i, 1ll)) arr[i][45-j] = 'd';
}
int lstdown = -1, lstright = -1;
int ptr = 87;
arr[0][1] = arr[1][0] = '.';
FOR(t, 2, 46){
if (fib[ptr] <= k){
lstright = t;
arr[0][t] = 'X';
k -= fib[ptr];
}
else arr[0][t] = '.';
ptr--;
if (fib[ptr] <= k){
lstdown = t;
arr[t][0] = 'X';
k -= fib[ptr];
}
else arr[t][0] = '.';
ptr--;
}
if (lstdown != -1 && lstright != -1){
arr[0][0] = 'X';
arr[lstdown][0] = 'r';
arr[0][lstright] = 'd';
}
else if (lstdown != -1) {
arr[0][0] = 'd';
arr[lstdown][0] = 'r';
}
else {
arr[0][0] = 'r';
arr[0][lstright] = 'd';
}
REP(i, 47){
if (i < 46){
arr[i][46] = 'd';
continue;
}
REP(j, 46) arr[i][j] = 'r';
}
arr[46][46] = '.';
REP(i, 47){
REP(j, 47) cout<<arr[i][j];
cout<<endl;
}
}
/*
3 1
2 1 3
2 4 4
2 1 1
2
2
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |