QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686307#7813. 密码锁MrPython100 ✓3ms3816kbC++141.4kb2024-10-29 10:57:102024-10-29 10:57:11

Judging History

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

  • [2024-10-29 10:57:11]
  • 评测
  • 测评结果:100
  • 用时:3ms
  • 内存:3816kb
  • [2024-10-29 10:57:10]
  • 提交

answer

#include<bits/extc++.h>
using namespace std;
using ui=unsigned int;
using uli=unsigned long long int;
using li=long long int;
namespace pbds=__gnu_pbds;
static constexpr ui pows[6]={100000,10000,1000,100,10,1};
struct Pswd{
    ui x;
    friend istream& operator>>(istream& in,Pswd& x){
        x.x=0;
        for (signed char i=0;i<5;++i){
            char k;
            in>>k;
            x.x=x.x*10+k-'0';
        }
        return in;
    }
    signed char operator[](unsigned char p){return x%pows[p]/pows[p+1];}
};
bool check(Pswd a,Pswd b){
    signed char p0=-1,p1=-1;
    for (unsigned char i=0;i<5;++i) if (a[i]!=b[i]){
        if (p0==-1) p0=i;
        else if (p1==-1) p1=i;
        else return false;
    }
    if (p1==-1) return true;
    else
        if (p1-p0!=1) return false;
        else return (a[p0]-b[p0]+10)%10==(a[p1]-b[p1]+10)%10;
}
int main(void){
#ifndef DEBUG
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
    size_t n;
    cin>>n;
    vector<Pswd> status(n);
    for (Pswd& i:status) cin>>i;
    size_t ans=0;
    for (ui i=0;i<=99999;++i){
        Pswd now{i};
        bool flag=true;
        for (Pswd j:status) if (j.x==i||!check(now,j)){flag=false;break;}
        ans+=flag;
    #ifdef DEBUG
        if (flag) cout<<now.x<<'\n';
    #endif
    }
    cout<<ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 3ms
memory: 3608kb

input:

1
4 9 8 2 5

output:

81

result:

ok single line: '81'

Test #2:

score: 10
Accepted
time: 3ms
memory: 3816kb

input:

1
7 7 5 2 0

output:

81

result:

ok single line: '81'

Test #3:

score: 10
Accepted
time: 3ms
memory: 3544kb

input:

1
8 9 8 7 8

output:

81

result:

ok single line: '81'

Test #4:

score: 10
Accepted
time: 3ms
memory: 3544kb

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: 3ms
memory: 3520kb

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: 3ms
memory: 3484kb

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: 3ms
memory: 3484kb

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: 3ms
memory: 3596kb

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: 3ms
memory: 3532kb

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: 3ms
memory: 3536kb

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'