Submission #47355091


Source Code Expand

#include <bits/stdc++.h>
#define int long long

using namespace std;

int a[20][20];
int cntx[20][20], cnty[20][20], cnt[10];

signed main() {
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            cin >> a[i][j];
            // 判断每一行每一列是否有相同的数字
            cntx[i][a[i][j]]++;
            cnty[j][a[i][j]]++;
            if (cntx[i][a[i][j]] > 1 || cnty[j][a[i][j]] > 1) {
                cout << "No";
                return 0;
            }
        }
    }
    for (int x = 1; x <= 9; x += 3) { // 枚举行的起点
        for (int y = 1; y <= 9; y += 3) { // 枚举列的起点
            memset(cnt, 0, sizeof(cnt));
            // 判断每个小矩阵
            for (int i = x; i < x + 3; i++) {
                for (int j = y; j < y + 3; j++) {
                    cnt[a[i][j]]++;
                    if (cnt[a[i][j]] > 1) {
                        cout << "No";
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes";
    return 0;
}

Submission Info

Submission Time
Task C - Number Place
User yhx0322
Language C++ 20 (gcc 12.2)
Score 250
Code Size 1115 Byte
Status AC
Exec Time 1 ms
Memory 3684 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 3676 KiB
example_01.txt AC 1 ms 3560 KiB
example_02.txt AC 1 ms 3476 KiB
hand_00.txt AC 1 ms 3552 KiB
hand_01.txt AC 1 ms 3636 KiB
hand_02.txt AC 1 ms 3612 KiB
random_00.txt AC 1 ms 3436 KiB
random_01.txt AC 1 ms 3544 KiB
random_02.txt AC 1 ms 3484 KiB
random_03.txt AC 1 ms 3440 KiB
random_04.txt AC 1 ms 3460 KiB
random_05.txt AC 1 ms 3512 KiB
random_06.txt AC 1 ms 3516 KiB
random_07.txt AC 1 ms 3480 KiB
random_08.txt AC 1 ms 3540 KiB
random_09.txt AC 1 ms 3436 KiB
random_10.txt AC 1 ms 3480 KiB
random_11.txt AC 1 ms 3644 KiB
random_12.txt AC 1 ms 3476 KiB
random_13.txt AC 1 ms 3684 KiB
random_14.txt AC 1 ms 3460 KiB
random_15.txt AC 1 ms 3464 KiB
random_16.txt AC 1 ms 3560 KiB
random_17.txt AC 1 ms 3480 KiB
random_18.txt AC 1 ms 3548 KiB
random_19.txt AC 1 ms 3684 KiB
random_20.txt AC 1 ms 3548 KiB
random_21.txt AC 1 ms 3480 KiB
random_22.txt AC 1 ms 3516 KiB
random_23.txt AC 1 ms 3456 KiB
random_24.txt AC 1 ms 3516 KiB