Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cpp] swea1974 #14

Merged
merged 2 commits into from
Jul 16, 2023
Merged

[cpp] swea1974 #14

merged 2 commits into from
Jul 16, 2023

Conversation

minjae9610
Copy link
Member

@minjae9610 minjae9610 commented Jul 15, 2023

πŸ“£ Related Issue

🌁 Background

SWEA μ•Œκ³ λ¦¬μ¦˜ Track λ‚œμ΄λ„ 쀑 문제 풀이

πŸ‘©β€πŸ’» Contents

[D2] μŠ€λ„μΏ  검증 - 1974

image
image

#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int T;
    cin >> T;
    for (int test_case = 1; test_case <= T; ++test_case)
    {
        bool row_check[9][9] = { false };
        bool col_check[9][9] = { false };
        bool square_check[9][9] = { false };
        bool result = true;

        for (int row = 0; row < 9; row++) {
            for (int col = 0; col < 9; col++) {
                int slot;
                cin >> slot;
                if (!result)
                    continue;
                int square = (row / 3) * 3 + col / 3;
                if (!row_check[row][slot - 1] and !col_check[col][slot - 1] and !square_check[square][slot - 1])
                    row_check[row][slot - 1] = col_check[col][slot - 1] = square_check[square][slot - 1] = true;
                else
                    result = false;
            }
        }
        cout << '#' << test_case << ' ' << result << '\n';
    }

    return 0;
}

πŸ“± Screenshot

image

πŸ“ Review Note

경우의 μˆ˜κ°€ μ μ–΄μ„œ μ‘°κ±΄λ³„λ‘œ 반볡으둜 풀어도 λ˜μ§€λ§Œ DPλ₯Ό μ μš©ν•œλ‹€λ©΄ 반볡 횟수λ₯Ό 쀄일 수 μžˆλ‹€.
그래봀자 9x9의 고정크기이기 λ•Œλ¬Έμ— μ‹œκ°„λ³΅μž‘λ„λŠ” O(1)의 μƒμˆ˜μ‹œκ°„μ„ κ°€μ§€κ²Œ λ˜λŠ”κ±΄ λ§ˆμ°¬κ°€μ§€...

πŸ“¬ Reference

@minjae9610 minjae9610 added μ•Œκ³ λ¦¬μ¦˜ μ•Œκ³ λ¦¬μ¦˜ 문제 #DP SW Expert Academy SWEA 문제 labels Jul 15, 2023
@minjae9610 minjae9610 requested a review from a team as a code owner July 15, 2023 12:34
@minjae9610 minjae9610 requested review from gabalja and zini9188 and removed request for a team July 15, 2023 12:34
Copy link
Contributor

@zini9188 zini9188 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@minjae9610 minjae9610 merged commit 55f99c6 into main Jul 16, 2023
@minjae9610 minjae9610 deleted the algo/minjae9610/swea1974 branch July 16, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#DP SW Expert Academy SWEA 문제 μ•Œκ³ λ¦¬μ¦˜ μ•Œκ³ λ¦¬μ¦˜ 문제
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants