This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair <int, int>
#define ull unsigned long long
// #define int long long
// #define int unsigned long long
const ll inf = 1e9 + 7;
const ll weirdMod = 998244353;
ll n;
char arr[61][62];
// dir = 0, down
// dir = 1, right
int dfs(int x, int y, int dir) {
if (x > 4 || y > 4) return 1;
if (arr[x][y] == 'X') return dfs(x + 1, y, 0) + dfs(x, y + 1, 1);
if (dir == 0) return dfs(x + 1, y, 0);
return dfs(x, y + 1, 1);
}
void go20() {
for (int i = 0; i < (1 << 16); i++) {
for (int j = 1; j <= 16; j++) {
if ((i >> (j - 1)) % 2 == 1) {
if (j % 4 == 0) arr[j / 4][4] = 'X';
else arr[j / 4 + 1][j % 4] = 'X';
} else {
if (j % 4 == 0) arr[j / 4][4] = '.';
else arr[j / 4 + 1][j % 4] = '.';
}
} if (arr[1][1] != 'X') continue;
if (dfs(1, 1, 0) == n) {
cout << "5 5\n";
for (int j = 1; j <= 5; j++) {
for (int k = 1; k <= 5; k++) {
if (j == 5 && k == 5) cout << '.';
else if (j == 5) cout << 'r';
else if (k == 5) cout << 'd';
else cout << arr[j][k];
} cout << '\n';
} return;
}
}
}
void go80() {
ll t = n; int cnt = -1;
while (t) { cnt++; t >>= 1; }
cout << cnt + 1 << ' ' << cnt + 2 << '\n';
for (int i = 1; i <= cnt + 1; i++)
for (int j = 1; j <= cnt + 2; j++) arr[i][j] = '.';
for (int i = 1; i <= cnt + 1; i++) arr[i][cnt + 2] = 'd';
for (int j = 1; j <= cnt + 2; j++) arr[cnt + 1][j] = 'r';
int r = cnt + 1; cout << cnt << '\n';
for (int i = 1; cnt > 1; i++, cnt--)
for (int j = 2; j <= r; j++) arr[i][j] = 'X';
for (int i = 1; i <= cnt + 1; i++) {
for (int j = 1; j <= cnt + 2; j++)
cout << arr[i][j] << ' ';
cout << '\n';
}
}
void solve() {
cin >> n;
if (n <= 19) go20();
else go80();
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
cout << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |