QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555158#7813. 密码锁cjh2007100 ✓1ms3948kbC++142.6kb2024-09-09 20:17:412024-09-09 20:17:42

Judging History

你现在查看的是最新测评结果

  • [2024-09-09 20:17:42]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:3948kb
  • [2024-09-09 20:17:41]
  • 提交

answer

#include <iostream>
#include <cstdio>

using namespace std;

int n, s[10][10];

inline bool check(int a, int aa, int b, int bb) {
    int A = a, B = b;
    for (int i = 1; i <= 9; i ++ ) {
        A ++ ; B ++ ;
        if (A == 10) A = 0;
        if (B == 10) B = 0;
        if (A == aa && B == bb) return true;
    }
    A = a, B = b;
    for (int i = 1; i <= 9; i ++ ) {
        A -- ; B -- ;
        if (A == -1) A = 9;
        if (B == -1) B = 9;
        if (A == aa && B == bb) return true;
    }
    return false;
}

int main() {
    // freopen("lock.in", "r", sdtin);
    // freopen("lock.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++ )
        for (int j = 1; j <= 5; j ++ ) scanf("%d", &s[i][j]);
    int cnt = 0;
    for (int a = 0; a <= 9; a ++ ) {
        for (int b = 0; b <= 9; b ++ ) {
            for (int c = 0; c <= 9; c ++ ) {
                for (int d = 0; d <= 9; d ++ ) {
                    for (int e = 0; e <= 9; e ++ ) {
                        bool flag = true;
                        for (int i = 1; i <= n; i ++ ) {
                            if (s[i][1] == a && s[i][2] == b && s[i][3] == c && s[i][4] == d && s[i][5] == e) {
                                flag = false;
                                break;
                            }
                            if (s[i][1] == a && s[i][2] == b && s[i][3] == c && s[i][4] == d) continue;
                            if (s[i][1] == a && s[i][2] == b && s[i][3] == c && s[i][5] == e) continue;
                            if (s[i][1] == a && s[i][2] == b && s[i][4] == d && s[i][5] == e) continue;
                            if (s[i][1] == a && s[i][3] == c && s[i][4] == d && s[i][5] == e) continue;
                            if (s[i][2] == b && s[i][3] == c && s[i][4] == d && s[i][5] == e) continue;
                            if (s[i][1] == a && s[i][2] == b && s[i][3] == c && check(d, s[i][4], e, s[i][5])) continue;
                            if (s[i][1] == a && s[i][2] == b && s[i][5] == e && check(c, s[i][3], d, s[i][4])) continue;
                            if (s[i][1] == a && s[i][4] == d && s[i][5] == e && check(b, s[i][2], c, s[i][3])) continue;
                            if (s[i][3] == c && s[i][4] == d && s[i][5] == e && check(a, s[i][1], b, s[i][2])) continue;
                            flag = false;
                            break;
                        }
                        if (flag) cnt ++ ;
                    }
                }
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 1ms
memory: 3896kb

input:

1
4 9 8 2 5

output:

81

result:

ok single line: '81'

Test #2:

score: 10
Accepted
time: 0ms
memory: 3768kb

input:

1
7 7 5 2 0

output:

81

result:

ok single line: '81'

Test #3:

score: 10
Accepted
time: 0ms
memory: 3820kb

input:

1
8 9 8 7 8

output:

81

result:

ok single line: '81'

Test #4:

score: 10
Accepted
time: 0ms
memory: 3920kb

input:

2
0 3 7 3 8
0 3 6 7 8

output:

6

result:

ok single line: '6'

Test #5:

score: 10
Accepted
time: 0ms
memory: 3916kb

input:

2
7 3 7 9 7
3 3 7 9 3

output:

2

result:

ok single line: '2'

Test #6:

score: 10
Accepted
time: 0ms
memory: 3892kb

input:

4
8 6 9 9 4
8 6 8 9 4
8 6 7 9 4
8 6 1 9 4

output:

6

result:

ok single line: '6'

Test #7:

score: 10
Accepted
time: 0ms
memory: 3908kb

input:

6
0 8 3 9 0
0 4 3 9 0
0 0 3 9 0
0 3 3 9 0
0 5 3 9 0
0 6 3 9 0

output:

4

result:

ok single line: '4'

Test #8:

score: 10
Accepted
time: 0ms
memory: 3836kb

input:

7
2 2 5 6 3
1 8 5 6 3
2 8 7 6 3
2 8 6 6 3
2 8 8 6 3
2 1 5 6 3
2 8 9 6 3

output:

1

result:

ok single line: '1'

Test #9:

score: 10
Accepted
time: 0ms
memory: 3948kb

input:

5
6 6 6 9 5
6 0 0 9 5
6 1 1 9 5
6 2 2 9 5
6 4 4 9 5

output:

5

result:

ok single line: '5'

Test #10:

score: 10
Accepted
time: 0ms
memory: 3904kb

input:

8
9 0 8 6 0
9 5 2 6 0
9 0 7 0 4
9 0 9 6 0
3 0 7 6 0
9 0 7 6 7
4 0 7 6 0
9 8 7 6 0

output:

1

result:

ok single line: '1'