QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875156#7813. 密码锁Physics212303100 ✓1ms3712kbC++17831b2025-01-29 11:22:442025-01-29 11:22:45

Judging History

This is the latest submission verdict.

  • [2025-01-29 11:22:45]
  • Judged
  • Verdict: 100
  • Time: 1ms
  • Memory: 3712kb
  • [2025-01-29 11:22:44]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  int n,c=0; cin>>n;
  vector<array<int,5> > a(n);
  for(auto &i:a)for(auto &j:i)cin>>j;
  auto pd=[&](array<int,5> x)->bool{
    for(int i=1;i<n;i++){
      set<int> t; vector<int> p;
      for(int j=0;j<5;j++)
        if(x[j]!=a[i][j])t.emplace((a[i][j]-x[j]+10)%10),p.emplace_back(j);
      bool f=false;
      if(p.size()==1||p.size()==2&&p[1]-p[0]==1)f=true;
      if(t.size()!=1||!f)return false;
    }
    return true;
  };
  for(int i=0;i<5;i++)
    for(int j=1;j<=9;j++){
      array<int,5> b=a[0]; (b[i]+=j)%=10;
      if(pd(b))c++;
    }
  for(int i=0;i<4;i++)
    for(int j=1;j<=9;j++){
      array<int,5> b=a[0]; (b[i]+=j)%=10,(b[i+1]+=j)%=10;
      if(pd(b))c++;
    }
  cout<<c<<endl;
  return 0;
}

详细


Pretests


Final Tests

Test #1:

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

input:

1
4 9 8 2 5

output:

81

result:

ok single line: '81'

Test #2:

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

input:

1
7 7 5 2 0

output:

81

result:

ok single line: '81'

Test #3:

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

input:

1
8 9 8 7 8

output:

81

result:

ok single line: '81'

Test #4:

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

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

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

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: 1ms
memory: 3584kb

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: 1ms
memory: 3712kb

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

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

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'