Submission #1100758

# Submission time Handle Problem Language Result Execution time Memory
1100758 2024-10-14T15:30:46 Z Kirill22 Costinland (info1cup19_costinland) C++17
100 / 100
2 ms 760 KB
#include "bits/stdc++.h"

using namespace std;

void solve() {
    long long k;
    cin >> k;
    int n = 500;
    vector<string> a(n, string(n, '.'));
    int x = 0, y = 0;
    while (1) {
        if (k <= 1) {
            // x, y
            for (int i = 0; i <= y; i++) {
                a[x + 1][i] = 'r';
            }
            for (int i = 0; i <= x; i++) {
                a[i][y + 1] = 'd';
            }
            break;
        }
        if (k == 2) {
            a[x][y] = 'X';
            k = 0;
            continue;
        }
        if (k == 3) {
            if (x < y) {
                a[x][y] = a[x + 1][y] = 'X';
                x += 1;
            } else {
                a[x][y] = a[x][y + 1] = 'X';
                y += 1;
            }
            k = 0;
            continue;
        }
        if (k == 4) {
            a[x][y] = a[x + 1][y] = a[x][y + 1] = 'X';
            x++, y++;
            k = 0;
            continue;
        }
        if (k < 6) {
            a[x][y] = 'X';
            k--;
            if (x < y) {
                x++;
            } else {
                y++;
            }
            continue;
        }
        if (k % 6 == 0) {
            a[x][y] = a[x + 1][y] = a[x + 1][y + 1] = a[x][y + 1] = 'X';
            a[x + 2][y] = a[x + 2][y + 1] = 'r';
            a[x][y + 2] = a[x + 1][y + 2] = 'd';
            x += 2, y += 2;
            k /= 6;
            continue;
        }
        a[x][y] = 'X';
        if (k % 6 == 1) {
            a[x][y] = a[x + 1][y] = a[x + 1][y + 1] = a[x][y + 1] = 'X';
            a[x + 2][y] = a[x + 2][y + 1] = 'r';
            a[x][y + 2] = a[x + 1][y + 2] = 'd';
            a[x + 2][y] = 'X';
            x += 2, y += 2;
            k /= 6;
        } else if (k % 6 == 2) {
            a[x][y] = a[x + 1][y] = a[x + 1][y + 1] = a[x][y + 1] = 'X';
            a[x + 2][y] = a[x + 2][y + 1] = 'r';
            a[x][y + 2] = a[x + 1][y + 2] = 'd';
            a[x + 2][y] = a[x][y + 2] = 'X';
            x += 2, y += 2;
            k /= 6;
        } else if (k % 6 == 3) {
            a[x][y] = a[x + 1][y] = a[x + 1][y + 1] = a[x][y + 1] = 'X';
            a[x + 2][y] = a[x + 2][y + 1] = 'r';
            a[x][y + 2] = a[x + 1][y + 2] = 'd';
            a[x + 2][y + 1] = 'X';
            x += 2, y += 2;
            k /= 6;
        } else if (k % 6 == 4) {
            a[x][y] = a[x + 1][y] = a[x + 1][y + 1] = a[x][y + 1] = 'X';
            a[x + 2][y] = a[x + 2][y + 1] = 'r';
            a[x][y + 2] = a[x + 1][y + 2] = 'd';
            a[x + 2][y] = a[x + 2][y + 1] = 'X';
            x += 2, y += 2;
            k /= 6;
        } else if (k % 6 == 5) {
            a[x][y] = a[x + 1][y] = a[x + 1][y + 1] = a[x][y + 1] = 'X';
            a[x + 2][y] = a[x + 2][y + 1] = 'r';
            a[x][y + 2] = a[x + 1][y + 2] = 'd';
            a[x + 2][y] = a[x + 2][y + 1] = a[x][y + 2] = 'X';
            x += 2, y += 2;
            k /= 6;
        }
    }
    int N = 0, M = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i][j] != '.') {
                N = max(N, i + 1);
                M = max(M, j + 1);
            }
        }
    }
    cout << N << " " << M << '\n';
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cout << a[i][j];
        }
        cout << '\n';
    }
};

/*
XX
XX
 */

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 592 KB Correct! Your size: 3
2 Correct 1 ms 592 KB Correct! Your size: 3
3 Correct 2 ms 592 KB Correct! Your size: 4
4 Correct 1 ms 592 KB Correct! Your size: 4
5 Correct 1 ms 592 KB Correct! Your size: 4
6 Correct 1 ms 592 KB Correct! Your size: 4
7 Correct 1 ms 592 KB Correct! Your size: 4
8 Correct 1 ms 592 KB Correct! Your size: 4
9 Correct 1 ms 592 KB Correct! Your size: 5
# Verdict Execution time Memory Grader output
1 Correct 1 ms 592 KB Correct! Your size: 46
2 Correct 1 ms 592 KB Correct! Your size: 47
3 Correct 1 ms 592 KB Correct! Your size: 48
4 Correct 1 ms 592 KB Correct! Your size: 47
5 Correct 1 ms 760 KB Correct! Your size: 48
6 Correct 1 ms 592 KB Correct! Your size: 48
7 Correct 1 ms 592 KB Correct! Your size: 48
8 Correct 1 ms 592 KB Correct! Your size: 46