fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5.  
  6. ll k;
  7. int n;
  8. vector<int> v;
  9. string ans[49], pa[7]={"", "....", "X...", "XX..", "XXX.", "XdXX", "XXXX"};
  10.  
  11. int main() {
  12. ios::sync_with_stdio(0);
  13. cin.tie(0);
  14.  
  15. cin >> k;
  16. while(k) {
  17. v.push_back(k%6);
  18. k/=6;
  19. }
  20. n=2*v.size()+1;
  21. for(int i=0; i<n; ++i) {
  22. ans[i]=string(n, i<n-1?'.':'r');
  23. ans[i][n-1]=i<n-1?'d':'.';
  24. }
  25. auto p=[&](int i, int x, int y) {
  26. ans[i][i+2]=ans[i+1][i+2]='d';
  27. ans[i+2][i]=ans[i+2][i+1]='r';
  28. for(int j1 : {0, 1})
  29. for(int j2 : {0, 1})
  30. ans[i+j1][i+j2]=pa[x][j1*2+j2];
  31. if(y%3)
  32. ans[i+2][i]='X';
  33. if(y%3==2)
  34. ans[i][i+2]='X';
  35. if(y>=3)
  36. ans[i+1][i+2]='X';
  37. };
  38. for(int i=0; i<v.size(); ++i)
  39. p(2*i, i+1<v.size()?6:v[i], i+1<v.size()?v[i]:0);
  40. cout << n << " " << n << "\n";
  41. for(int i=0; i<n; ++i)
  42. cout << ans[i] << "\n";
  43. }
Success #stdin #stdout 0s 15240KB
stdin
39
stdout
7 7
XXd...d
XXX...d
rrXXd.d
..XXd.d
..rr..d
......d
rrrrrr.