QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#605906 | #7813. 密码锁 | tiankonguse | 100 ✓ | 0ms | 3872kb | C++20 | 1.4kb | 2024-10-02 20:32:53 | 2024-10-02 20:32:54 |
Judging History
answer
/*
ID: tiankonguse
TASK: lock
LANG: C++
CONTEST: CSP-S 2023
OJ: https://qoj.ac/problem/7813
*/
#define TASK "lock"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void InitIO() {
// #ifndef USACO_LOCAL_JUDGE
// freopen(TASK ".in", "r", stdin);
// freopen(TASK ".out", "w", stdout);
// #endif
}
/*
*/
unordered_map<ll, ll> h;
vector<ll> base = {1, 10, 100, 1000, 10000, 100000};
const int N = 5;
const int M = 9;
ll Flap(const ll num, int i, int j){
int v = (num/base[i]) % 10;
ll V = (v + j) % 10;
return num - v * base[i] + V * base[i];
}
void SolverOne(const ll num){
// 1 个
for(int i=0;i<N;i++){
for(int j=1;j<=M;j++){
const ll newNum = Flap(num, i, j);
h[newNum]++;
}
}
// 转动两个
for(int i=1;i<N;i++){
for(int j=1;j<=M;j++){
const ll newNum = Flap(Flap(num, i-1, j), i, j);
h[newNum]++;
}
}
}
void Solver() { //
ll n;
scanf("%lld", &n);
for (ll i = 0; i < n; i++) {
ll num = 0;
for (int j = 0; j < N; j++) {
ll v = 0;
scanf("%lld", &v);
num = num * 10 + v;
}
SolverOne(num);
}
ll ans = 0;
for(auto [k,v] : h){
if(v == n){
ans++;
}
}
printf("%lld\n", ans);
}
int main() {
InitIO();
Solver();
return 0;
}
/*
1
0 0 1 1 5
*/
詳細信息
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 0ms
memory: 3784kb
input:
1 4 9 8 2 5
output:
81
result:
ok single line: '81'
Test #2:
score: 10
Accepted
time: 0ms
memory: 3800kb
input:
1 7 7 5 2 0
output:
81
result:
ok single line: '81'
Test #3:
score: 10
Accepted
time: 0ms
memory: 3796kb
input:
1 8 9 8 7 8
output:
81
result:
ok single line: '81'
Test #4:
score: 10
Accepted
time: 0ms
memory: 3860kb
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: 3744kb
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: 3812kb
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: 3872kb
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: 3812kb
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: 3800kb
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: 3832kb
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'