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 <stdio.h>
#define N 49
int main() {
static char cc[N][N + 1];
int n, i, j;
long long k;
scanf("%lld", &k);
n = 0;
while (k >= 6) {
cc[n + 0][n + 0] = 'X', cc[n + 0][n + 1] = 'X', cc[n + 0][n + 2] = 'd';
cc[n + 1][n + 0] = 'X', cc[n + 1][n + 1] = 'X', cc[n + 1][n + 2] = 'd';
cc[n + 2][n + 0] = 'r', cc[n + 2][n + 1] = 'r', cc[n + 2][n + 2] = '.';
if (k / 3 % 2 == 1)
cc[n + 1][n + 2] = 'X';
if (k % 3 == 1)
cc[n + 0][n + 2] = 'X';
else if (k % 3 == 2)
cc[n + 0][n + 2] = 'X', cc[n + 2][n + 0] = 'X';
n += 2, k /= 6;
}
if (k == 1)
cc[n + 0][n + 0] = '.';
else if (k == 2) {
cc[n + 0][n + 0] = 'X', cc[n + 0][n + 1] = 'd';
cc[n + 1][n + 0] = 'r', cc[n + 1][n + 1] = '.';
n++;
} else if (k == 3) {
cc[n + 0][n + 0] = 'X', cc[n + 0][n + 1] = 'X', cc[n + 0][n + 2] = 'd';
cc[n + 1][n + 0] = 'd', cc[n + 1][n + 1] = 'd', cc[n + 1][n + 2] = 'd';
cc[n + 2][n + 0] = 'r', cc[n + 2][n + 1] = 'r', cc[n + 2][n + 2] = '.';
n += 2;
} else if (k == 4) {
cc[n + 0][n + 0] = 'X', cc[n + 0][n + 1] = 'd', cc[n + 0][n + 2] = 'd';
cc[n + 1][n + 0] = 'r', cc[n + 1][n + 1] = 'X', cc[n + 1][n + 2] = 'd';
cc[n + 2][n + 0] = 'r', cc[n + 2][n + 1] = 'r', cc[n + 2][n + 2] = '.';
n += 2;
} else {
cc[n + 0][n + 0] = 'X', cc[n + 0][n + 1] = 'X', cc[n + 0][n + 2] = 'd';
cc[n + 1][n + 0] = 'r', cc[n + 1][n + 1] = 'X', cc[n + 1][n + 2] = 'd';
cc[n + 2][n + 0] = 'r', cc[n + 2][n + 1] = 'r', cc[n + 2][n + 2] = '.';
n += 2;
}
n++;
printf("%d %d\n", n, n);
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
if (cc[i][j] == 0)
cc[i][j] = '.';
for (i = 0; i + 1 < n; i++)
cc[i][n - 1] = 'd';
for (j = 0; j + 1 < n; j++)
cc[n - 1][j] = 'r';
for (i = 0; i < n; i++)
printf("%s\n", cc[i]);
return 0;
}
Compilation message (stderr)
costinland.c: In function 'main':
costinland.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | scanf("%lld", &k);
| ^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |