Submission #47287424


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[10][10];

void solve(std::istream& is, std::ostream& os) {
    for(Num y{0}; y<9; ++y) {
        for(Num x{0}; x<9; ++x) {
            Num a {0};
            is >> a;
            grid[y][x] = a;
        }
    }

    bool valid {true};

    for(Num y{0}; y<9; ++y) {
        std::set<Num> nums;
        for(Num x{0}; x<9; ++x) {
            const auto a = grid[y][x];
            nums.insert(a);
        }
        valid &= nums.size() == 9;
    }

    for(Num x{0}; x<9; ++x) {
        std::set<Num> nums;
        for(Num y{0}; y<9; ++y) {
            const auto a = grid[y][x];
            nums.insert(a);
        }
        valid &= nums.size() == 9;
    }

    for(Num box_x{0}; box_x<9; box_x+=3) {
        for(Num box_y{0}; box_y<9; box_y+=3) {
            std::set<Num> nums;

            for(Num ofs_x{0}; ofs_x<3; ++ofs_x) {
                for(Num ofs_y{0}; ofs_y<3; ++ofs_y) {
                    const auto x = box_x + ofs_x;
                    const auto y = box_y + ofs_y;
                    const auto a = grid[y][x];
                    nums.insert(a);
                }
            }
            valid &= nums.size() == 9;
        }
    }

    if (valid) {
        os << "Yes\n";
    } else {
        os << "No\n";
    }
}

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

Submission Info

Submission Time
Task C - Number Place
User zettsut
Language C++ 20 (gcc 12.2)
Score 250
Code Size 1933 Byte
Status AC
Exec Time 1 ms
Memory 3660 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 3
AC × 31
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, random_00.txt, 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, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3556 KiB
example_01.txt AC 1 ms 3508 KiB
example_02.txt AC 1 ms 3440 KiB
hand_00.txt AC 1 ms 3556 KiB
hand_01.txt AC 1 ms 3560 KiB
hand_02.txt AC 1 ms 3468 KiB
random_00.txt AC 1 ms 3628 KiB
random_01.txt AC 1 ms 3512 KiB
random_02.txt AC 1 ms 3568 KiB
random_03.txt AC 1 ms 3504 KiB
random_04.txt AC 1 ms 3560 KiB
random_05.txt AC 1 ms 3440 KiB
random_06.txt AC 1 ms 3524 KiB
random_07.txt AC 1 ms 3548 KiB
random_08.txt AC 1 ms 3560 KiB
random_09.txt AC 1 ms 3572 KiB
random_10.txt AC 1 ms 3556 KiB
random_11.txt AC 1 ms 3508 KiB
random_12.txt AC 1 ms 3472 KiB
random_13.txt AC 1 ms 3560 KiB
random_14.txt AC 1 ms 3440 KiB
random_15.txt AC 1 ms 3660 KiB
random_16.txt AC 1 ms 3464 KiB
random_17.txt AC 1 ms 3500 KiB
random_18.txt AC 1 ms 3524 KiB
random_19.txt AC 1 ms 3552 KiB
random_20.txt AC 1 ms 3516 KiB
random_21.txt AC 1 ms 3552 KiB
random_22.txt AC 1 ms 3512 KiB
random_23.txt AC 1 ms 3560 KiB
random_24.txt AC 1 ms 3512 KiB