This commit is contained in:
Zengtudor 2024-10-25 11:41:50 +08:00
parent 1e9f0b6c84
commit 87df2b11c0
3 changed files with 118 additions and 0 deletions

BIN
src/CSP-S2023/CSP-S.pdf Normal file

Binary file not shown.

115
src/CSP-S2023/lock/lock.cpp Normal file
View File

@ -0,0 +1,115 @@
#include <algorithm>
#include <array>
#include <cstring>
#include <iostream>
#include <istream>
#include <iterator>
#include <ostream>
#include <set>
#include <utility>
using ll = long long;
using ull = unsigned long long;
const ll max_num = 6;
short n, arr[max_num];
std::set<std::array<short, max_num>> ans_set;
template<class T,size_t S>
std::ostream &operator<<(std::ostream &os, const std::array<T,S> &s){
os<<"array [ ";
if(!s.empty()){
auto now_it = s.begin();
const auto rbegin = s.rbegin();
while(*now_it!=*rbegin){
os<<*now_it<<", ";
++now_it;
}
os<<*rbegin<<" ]";
}else{
os<<"}";
}
return os;
}
template<class T>
std::ostream &operator<<(std::ostream &os, const std::set<T> &s){
os<<"set { ";
if(!s.empty()){
auto now_it = s.begin();
const auto rbegin = s.rbegin();
while(*now_it!=*rbegin){
os<<*now_it<<", ";
++now_it;
}
os<<*rbegin<<" }";
}else{
os<<"}";
}
return os;
}
#ifdef ONLINE_JUDGE
#define DEBUG(code)
#else
#define DEBUG(code)code
#endif
ll arr_to_ll(const ll *const arr){
ll ret{};
for(ll i{1};i<=5;i++){
DEBUG(std::cout<<ret<<'\n';)
ret=ret*10 + (arr[i]==0?-1:arr[i]);
}
DEBUG(std::cout<<ret<<'\n';)
return ret;
}
int main(){
std::iostream::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
std::cin>>n;
for(ll i{1};i<=n;i++){
for(ll j{1};j<=5;j++){
std::cin>>arr[j];
}
std::set<std::array<short, max_num>> tmp_set;
for(ll j{1};j<=5;j++){
for(ll k{1};k<=9;k++){
std::array<short, max_num> new_arr{};
memcpy(new_arr.begin(), arr, sizeof(arr));
new_arr[j] = (new_arr[j] + k) % 10;
DEBUG(
for(ll i{1};i<=5;i++){
std::cout<<new_arr[i]<<' ';
}
std::cout<<'\n';
)
tmp_set.insert(new_arr);
}
}
for(ll j{1};j<=4;j++){
for(ll k{1};k<=9;k++){
std::array<short, max_num> new_arr{};
memcpy(new_arr.begin(), arr, sizeof(arr));
new_arr[j] = (new_arr[j] + k) % 10;
new_arr[j+1] = (new_arr[j+1] + k) % 10;
DEBUG(
for(ll i{1};i<=5;i++){
std::cout<<new_arr[i]<<' ';
}
std::cout<<'\n';
)
tmp_set.insert(new_arr);
}
}
DEBUG(std::cout<<tmp_set<<'\n';)
std::set<std::array<short, max_num>> new_ans_set;
if(i!=1){
std::set_intersection(ans_set.begin(), ans_set.end(), tmp_set.begin(), tmp_set.end(), std::inserter(new_ans_set, new_ans_set.end()));
}else{
new_ans_set = std::move(tmp_set);
}
ans_set = std::move(new_ans_set);
DEBUG(std::cout<<ans_set<<'\n';)
}
std::cout<<ans_set.size()<<'\n';
}

View File

@ -13,8 +13,11 @@ void print(const Args&...args){
const ll max_m = 1e5;
ll n, m1, m2, arr1[max_m], arr2[max_m];
/*
*/
int main(){
read(n,m1,m2);
for(ll i{1};i<=m1;i++){