mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 13:48:48 +00:00
parent
5a5913ecf8
commit
6b572e15fa
78
Luogu/P9752/P9752.cpp
Normal file
78
Luogu/P9752/P9752.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
#include <iostream>
|
||||
#include <array>
|
||||
#include <set>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 10,
|
||||
M = 5;
|
||||
|
||||
int n, ans;
|
||||
std::array<int, M> a[N];
|
||||
std::set<std::array<int, M>> set_pre;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 0; j < M; j++) {
|
||||
cin >> a[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
std::set<std::array<int, M>> set_now;
|
||||
|
||||
// Type 1: Only one element is different.
|
||||
for (int j = 0; j < M; j++) {
|
||||
std::array<int, M> t = a[i];
|
||||
|
||||
for (int k = 0; k < 10; k++) {
|
||||
t[j] = (a[i][j] + k) % 10;
|
||||
|
||||
if (t[j] != a[i][j]) {
|
||||
set_now.emplace(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Type 2: Two adjacent elements are different.
|
||||
for (int j = 0; j + 1 < M; j++) {
|
||||
std::array<int, M> t = a[i];
|
||||
|
||||
for (int k = 0; k < 10; k++) {
|
||||
t[j] = (a[i][j] + k) % 10;
|
||||
t[j + 1] = (a[i][j + 1] + k) % 10;
|
||||
|
||||
if (t[j] != a[i][j]) {
|
||||
set_now.emplace(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 1) {
|
||||
ans = set_now.size();
|
||||
set_pre = set_now;
|
||||
} else {
|
||||
std::set<std::array<int, M>> set;
|
||||
|
||||
for (auto o : set_pre) {
|
||||
if (set_now.count(o)) {
|
||||
set.emplace(o);
|
||||
}
|
||||
}
|
||||
|
||||
ans = set.size();
|
||||
set_pre = set;
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
Luogu/P9752/data/P9752_1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_1.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_10.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_10.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_2.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_2.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_3.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_3.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_4.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_4.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_5.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_5.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_6.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_6.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_7.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_7.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_8.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_8.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_9.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/data/P9752_9.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/data/P9752_9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/samples/lock1.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/samples/lock1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/samples/lock1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/samples/lock1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/samples/lock2.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/samples/lock2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P9752/samples/lock2.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P9752/samples/lock2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user