Submission #160308

#TimeUsernameProblemLanguageResultExecution timeMemory
160308model_codeCostinland (info1cup19_costinland)C++17
100 / 100
1 ms208 KiB
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>

using namespace std;

int a[64];
char str[64][64];

int main ()
{
  //  freopen ("input", "r", stdin);
  //  freopen ("output1", "w", stdout);

    long long k;
    scanf ("%lld", &k);
    assert (3LL <= k && k <= 1000000000000000000LL);

    k -= 2LL;

    int p = 0;
    for (; k > 0LL; k /= 6LL)
        a[++p] = k % 6LL;

    str[0][0] = 'X';

    int ind = 1;

    if (a[p] == 1) str[0][1] = 'X';
    if (a[p] == 2) str[0][1] = str[1][0] = 'X';
    if (a[p] == 3) str[0][1] = str[0][2] = str[1][1] = 'X', str[1][2] = 'd', str[2][1] = 'r', ++ind;
    if (a[p] == 4) str[0][1] = str[1][0] = str[1][1] = 'X', str[1][2] = 'd', str[2][1] = 'r', ++ind;
    if (a[p] == 5) str[0][1] = str[0][2] = str[1][0] = str[1][1] = 'X', str[1][2] = 'd', str[2][1] = 'r', ++ind;

    --p;
    for (int i = p; i; --i)
    {
        str[ind][ind] = str[ind][ind + 1] = str[ind + 1][ind] = str[ind + 1][ind + 1] = 'X';
        str[ind + 2][ind] = str[ind + 2][ind + 1] = 'r';
        str[ind][ind + 2] = str[ind + 1][ind + 2] = 'd';

        if (a[i] >= 3)
        {
            a[i] -= 3;
            str[ind + 1][0] = 'X';
        }

        if (a[i])
        {
            --a[i];
            str[ind + 2][0] = 'X';
        }

        if (a[i]) str[0][ind + 2] = 'X';

        ind += 2;
    }

    str[ind][ind] = 'r';
    ++ind;
    for (int i = 0; i < ind; ++i)
        str[i][ind] = 'd',
        str[ind][i] = 'r';

    ++ind;
    printf ("%d %d\n", ind, ind);
   // printf ("%d\n", ind);
    //str[ind - 2][ind - 3] = 'X';
    for (int i = 0; i < ind; ++i, printf ("\n"))
        for (int j = 0; j < ind; ++j)
            if (str[i][j] == NULL) printf (".");
            else printf ("%c", str[i][j]);

    return 0;
}

Compilation message (stderr)

costinland.cpp: In function 'int main()':
costinland.cpp:72:30: warning: NULL used in arithmetic [-Wpointer-arith]
   72 |             if (str[i][j] == NULL) printf (".");
      |                              ^~~~
costinland.cpp:17:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     scanf ("%lld", &k);
      |     ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...