QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#276694#7813. 密码锁SoyTony100 ✓0ms3884kbC++141.4kb2023-12-06 09:35:322023-12-06 09:35:34

Judging History

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

  • [2023-12-06 09:35:34]
  • 评测
  • 测评结果:100
  • 用时:0ms
  • 内存:3884kb
  • [2023-12-06 09:35:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

inline int read(){
    int x=0,w=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
    while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return x*w;
}

int n;
int a[10][10];
int now[10],b[10];
int ans;

inline void check(){
    bool chk=true;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=5;++j){
            b[j]=(a[i][j]-now[j]+10)%10;
        }
        int p=0;
        for(int j=1;j<=5;++j){
            if(!b[j]) continue;
            if(!p){
                p=j;
                continue;
            }
            else{
                if(p!=j-1) chk=false;
                if(b[p]!=b[j]) chk=false;
            }
        }
        if(!p) chk=false;
    }
    if(chk) ++ans;
}


int main(){
    n=read();
    for(int i=1;i<=n;++i){
        for(int j=1;j<=5;++j){
            a[i][j]=read();
        }
    }
    for(int i=1;i<=5;++i){
        for(int k=1;k<=9;++k){
            for(int j=1;j<=5;++j) now[j]=a[1][j];
            now[i]=(now[i]+k)%10;
            check();
        }
    }
    for(int i=1;i<=4;++i){
        for(int k=1;k<=9;++k){
            for(int j=1;j<=5;++j) now[j]=a[1][j];
            now[i]=(now[i]+k)%10,now[i+1]=(now[i+1]+k)%10;
            check();
        }
    }
    printf("%d\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 9 8 2 5

output:

81

result:

ok single line: '81'

Test #2:

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

input:

1
7 7 5 2 0

output:

81

result:

ok single line: '81'

Test #3:

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

input:

1
8 9 8 7 8

output:

81

result:

ok single line: '81'

Test #4:

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

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: 3796kb

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: 3728kb

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: 3884kb

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: 3748kb

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: 3792kb

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: 3796kb

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'