This commit is contained in:
Zengtudor 2024-10-07 11:27:45 +08:00
parent 3b702d5e93
commit deb08dc743

View File

@ -17,7 +17,7 @@ static constexpr size_t MAX_N {(size_t)1e3+5};
static constexpr ull MOD {998244353}; static constexpr ull MOD {998244353};
static size_t n,m,k; static size_t n,m,k;
ull mtx[MAX_N][MAX_N]; ull mtx[MAX_N][MAX_N];
std::set<std::vector<ull>> s; std::set<std::pair<size_t,ull>> s;
template<class T> template<class T>
std::ostream&operator<<(std::ostream &os,const std::vector<T> &v)noexcept{ std::ostream&operator<<(std::ostream &os,const std::vector<T> &v)noexcept{
@ -29,12 +29,31 @@ std::ostream&operator<<(std::ostream &os,const std::vector<T> &v)noexcept{
return os; return os;
} }
template<class T>
size_t hashVector1(const std::vector<T>& vec) {
size_t seed = 0;
for (size_t i = 0; i < vec.size(); ++i) {
// 结合元素的值和其索引来生成哈希
seed ^= std::hash<T>()((vec[i]+i)*(i << 2)) + 0x9e3779b9 - ((vec[i]*(i<<32))<<4) + ((vec[i]+i)<<2);
}
return seed;
}
template<class T>
size_t hashVector2(const std::vector<T>& vec) {
size_t seed = 0;
for (size_t i = 0; i < vec.size(); ++i) {
// 结合元素的值和其索引来生成哈希
seed ^= std::hash<T>()((vec[i]+i)*(i << 3)) + MOD<<(i%32) - ((vec[i]*(i<<16))<<3) + ((vec[i]+i)<<3);
}
return seed;
}
void dfs(size_t x, size_t y){ void dfs(size_t x, size_t y){
if(x>n){ if(x>n){
// cout<<"x:"<<x<<" y:"<<y<<'\n'; // cout<<"x:"<<x<<" y:"<<y<<'\n';
std::vector<ull> v; std::vector<ull> v;
v.reserve(n+m);
for(size_t i=1;i<=n;i++){ for(size_t i=1;i<=n;i++){
ull ai {std::numeric_limits<decltype(ai)>::max()}; ull ai {std::numeric_limits<decltype(ai)>::max()};
for(size_t j=1;j<=m;j++){ for(size_t j=1;j<=m;j++){
@ -50,7 +69,8 @@ void dfs(size_t x, size_t y){
v.push_back(bj); v.push_back(bj);
} }
// cout<<v<<"\n"; // cout<<v<<"\n";
s.insert(v); // cout<<hashVector1(v)<<','<<hashVector2(v)<<'\n';
s.insert({hashVector1(v),hashVector2(v)});
return; return;
} }
for(ull i{1};i<=k;i++){ for(ull i{1};i<=k;i++){