#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<ll, ll, ll> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e18
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// input
template<class T> void IN(T& x) {cin >> x;}
template<class H, class... T> void IN(H& h, T&... t) {IN(h); IN(t...); }
// output
template<class T1, class T2> void OUT(const pair<T1,T2>& x);
template<class T> void OUT(const vector<T>& x);
template<class T> void OUT(const T& x) {cout << x;}
template<class H, class... T> void OUT(const H& h, const T&... t) {OUT(h); OUT(t...); }
template<class T1, class T2> void OUT(const pair<T1,T2>& x) {OUT(x.fi,' ',x.se);}
template<class T> void OUT(const vector<T>& x) {RE(i,x.size()) OUT(i==0?"":" ",x[i]);}
template<class... T> void OUTL(const T&... t) {OUT(t..., "\n"); }
template<class H> void OUTLS(const H& h) {OUTL(h); }
template<class H, class... T> void OUTLS(const H& h, const T&... t) {OUT(h,' '); OUTLS(t...); }
// dp
template<class T> bool ckmin(T&a, T&b) { bool bl = a > b; a = min(a,b); return bl;}
template<class T> bool ckmax(T&a, T&b) { bool bl = a < b; a = max(a,b); return bl;}
void program();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
program();
}
//===================//
// begin program //
//===================//
const int MX = 70;
const int N = (1<<20);
ll k, n;
ll dp[MX][MX];
ll dpr[MX][MX], dpd[MX][MX];
ll cnt[MX][MX];
string ans[MX];
ll calculate() {
memset(dpr,0,sizeof(dpr));
memset(dpd,0,sizeof(dpd));
dpr[0][0] = 1;
RE(i,n) RE(j,n) {
ll tot = dpr[i][j] + dpd[i][j];
if(ans[i][j] == 'r') dpr[i ][j+1] += tot;
if(ans[i][j] == 'd') dpd[i+1][j ] += tot;
if(ans[i][j] == 'X') dpd[i+1][j ] += tot, dpr[i][j+1] += tot;
if(ans[i][j] == '.') dpd[i+1][j] += dpd[i][j], dpr[i][j+1] += dpr[i][j];
}
return dpr[n-1][n-1] + dpd[n-1][n-1];
}
void program() {
IN(k);
n = k <= 19 ? 62 : 45;
RE(i,n) ans[i] = string(n,'.');
RE(i,n-1) ans[n-1][i] = 'r';
RE(i,n-1) ans[i][n-1] = 'd';
RE(i,n-1) ans[i+1][i] = 'r';
RE(i,n-1) ans[i][i+1] = 'd';
ans[0][0] = 'd';
ans[1][0] = 'd';
RE(i,n-3) ans[2+i][i] = 'd';
ll curTot = 1;
ll m = n-4; // "pyramid" size
memset(dp,0,sizeof(dp));
dp[0][0] = 1;
RE(i,m) {
RE(j,i+1) {
if(dp[i][j] && curTot + dp[i][j] <= k) {
curTot += dp[i][j];
ans[3+i][j] = 'X';
dp[i+1][j] += dp[i][j];
if(j == i) dp[i+1][j+1] += dp[i][j];
else dp[i ][j+1] += dp[i][j];
} else {
dp[i+1][j] += dp[i][j];
ans[3+i][j] = 'd';
}
}
}
ll remaining = k - curTot;
if(remaining) {
ans[1][0] = 'X';
ll highestBit = 0;
RE(i,62) if(remaining&(1ll<<i)) highestBit = i;
RE(i,highestBit) ans[i][i] = 'X';
remaining -= (1ll<<highestBit);
RE(i,62) if(remaining&(1ll<<i)) {
remaining -= (1ll<<i);
ans[i][i+1] = 'X';
}
}
OUTLS(n,n);
RE(i,n) OUTL(ans[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
2 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
3 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
4 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
5 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
6 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
7 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
8 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
9 |
Partially correct |
1 ms |
332 KB |
Partially Correct! Your size: 62 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Correct! Your size: 45 |
2 |
Correct |
1 ms |
332 KB |
Correct! Your size: 45 |
3 |
Correct |
1 ms |
332 KB |
Correct! Your size: 45 |
4 |
Correct |
1 ms |
332 KB |
Correct! Your size: 45 |
5 |
Correct |
2 ms |
332 KB |
Correct! Your size: 45 |
6 |
Correct |
1 ms |
332 KB |
Correct! Your size: 45 |
7 |
Correct |
1 ms |
332 KB |
Correct! Your size: 45 |
8 |
Correct |
1 ms |
332 KB |
Correct! Your size: 45 |