Submission #49096391


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/modint>

namespace {
    using ModInt [[maybe_unused]] = atcoder::modint998244353;
    using Num [[maybe_unused]] = long long int;
    using Vec [[maybe_unused]] = std::vector<Num>;
    using Set [[maybe_unused]] = std::set<Num>;
    using Mset [[maybe_unused]] = std::multiset<Num>;
    using Edges [[maybe_unused]] = std::vector<std::vector<Num>>;

    template<typename T>
    using Q [[maybe_unused]] = std::queue<T>;

    template<typename T>
    using PQ [[maybe_unused]] = std::priority_queue<T, std::vector<T>, std::greater<T>>;
}

Num grid[64][64];

void solve(std::istream& is, std::ostream& os) {
    Num n {0};
    is >> n;

    Num center = n / 2;
    Num lower = center - 1;
    Num upper = center + 1;
    Num serial = 1;
    Num x = lower;
    Num y = lower;

    for(;;) {
        while(y < upper) {
            ++y;
            grid[y][x] = serial;
            ++serial;
        }

        while(x < upper) {
            ++x;
            grid[y][x] = serial;
            ++serial;
        }

        while(y > lower) {
            --y;
            grid[y][x] = serial;
            ++serial;
        }

        while(x > lower) {
            --x;
            grid[y][x] = serial;
            ++serial;
        }

        if (x == 0) {
            break;
        }

        --x;
        grid[y][x] = serial;
        ++serial;
        --lower;
        ++upper;
    }

    for(Num y{0}; y<n; ++y) {
        for(Num x{0}; x<n; ++x) {
            if ((x == center) && (y == center)) {
                os << "T";
            } else {
                os << grid[y][x];
            }
            if ((x + 1) == n) {
                os << "\n";
            } else {
                os << " ";
            }
        }
    }
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

Submission Info

Submission Time
Task D - Loong and Takahashi
User zettsut
Language C++ 20 (gcc 12.2)
Score 350
Code Size 1929 Byte
Status AC
Exec Time 1 ms
Memory 3684 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 1
AC × 22
Set Name Test Cases
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 1 ms 3528 KiB
random_02.txt AC 1 ms 3484 KiB
random_03.txt AC 1 ms 3528 KiB
random_04.txt AC 1 ms 3488 KiB
random_05.txt AC 1 ms 3488 KiB
random_06.txt AC 1 ms 3624 KiB
random_07.txt AC 1 ms 3536 KiB
random_08.txt AC 1 ms 3472 KiB
random_09.txt AC 1 ms 3684 KiB
random_10.txt AC 1 ms 3496 KiB
random_11.txt AC 1 ms 3504 KiB
random_12.txt AC 1 ms 3492 KiB
random_13.txt AC 1 ms 3420 KiB
random_14.txt AC 1 ms 3492 KiB
random_15.txt AC 1 ms 3548 KiB
random_16.txt AC 1 ms 3436 KiB
random_17.txt AC 1 ms 3500 KiB
random_18.txt AC 1 ms 3564 KiB
random_19.txt AC 1 ms 3612 KiB
random_20.txt AC 1 ms 3548 KiB
random_21.txt AC 1 ms 3560 KiB
sample_01.txt AC 1 ms 3596 KiB