871342274
3795939406
分别是QQ大、小号。
已经退役啦。
大号(已荒废)
以上图片都有链接!
快读
#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
inline int rd()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}哈希表 from RdAt32
template<typename Key_Unsigned_Type,typename Value_Type,const uint RANGE,const uint SIZE>
class My_Hash_map
{
protected:
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef long long LL;
typedef unsigned long long ULL;
uint h[RANGE];
struct Node_base
{
protected:
Key_Unsigned_Type _key;
Value_Type _val;
public:
Node_base() noexcept =default;
constexpr Node_base(Key_Unsigned_Type n_key,Value_Type n_val) noexcept :_key(n_key),_val(n_val){}
const Key_Unsigned_Type &key() const noexcept
{
return _key;
}
Key_Unsigned_Type &Changeable_key() noexcept
{
return _key;
}
Value_Type &val() noexcept
{
return _val;
}
const Value_Type &val() const noexcept
{
return _val;
}
};
struct Node
{
Node_base infor;
uint ne;
const Key_Unsigned_Type &key() const noexcept
{
return infor.key();
}
Key_Unsigned_Type &Changeable_key() noexcept
{
return infor.Changeable_key();
}
Value_Type &val() noexcept
{
return infor.val();
}
const Value_Type &val() const noexcept
{
return infor.val();
}
}node[SIZE];
uint idx;
public:
My_Hash_map() noexcept :h{0U},idx(0U){};
struct iterator
{
public:
Node *p;
explicit iterator(Node *np):p(np){}
Node_base *operator->() noexcept
{
return addressof(p->infor);
}
iterator &operator++() noexcept
{
--p;
return *this;
}
bool operator==(const iterator &other) const noexcept
{
return p==other.p;
}
bool operator!=(const iterator &other) const noexcept
{
return p!=other.p;
}
};
struct const_iterator
{
public:
const Node *p;
explicit const_iterator(const Node *np):p(np){}
const_iterator(const iterator &it):p(it.p){}
const Node_base *operator->() const noexcept
{
return addressof(p->infor);
}
const_iterator &operator++() noexcept
{
--p;
return *this;
}
bool operator==(const const_iterator &other) const noexcept
{
return p==other.p;
}
bool operator!=(const const_iterator &other) const noexcept
{
return p!=other.p;
}
};
iterator begin() noexcept
{
return iterator(node+idx);
}
constexpr iterator end() noexcept __attribute__((const))
{
return iterator((Node*)node);
}
const_iterator cbegin() const noexcept
{
return const_iterator(node+idx);
}
constexpr const_iterator cend() const noexcept __attribute__((const))
{
return const_iterator(node);
}
iterator find(Key_Unsigned_Type key) noexcept
{
uint key_moded(key%RANGE);
for(uint i(h[key_moded]);i;i=node[i].ne)
{
if(node[i].key()==key)
return iterator(addressof(node[i]));
}
return end();
}
const_iterator find(Key_Unsigned_Type key) const noexcept
{
uint key_moded(key%RANGE);
for(uint i(h[key_moded]);i;i=node[i].ne)
{
if(node[i].key()==key)
return const_iterator(addressof(node[i]));
}
return cend();
}
iterator insert(Key_Unsigned_Type key,Value_Type val) noexcept
{
uint key_moded(key%RANGE);
for(uint i(h[key_moded]);i;i=node[i].ne)
{
if(node[i].key()==key)
return iterator(addressof(node[i]));
}
node[++idx]={Node_base(key,val),h[key_moded]};
h[key_moded]=idx;
return iterator(addressof(node[idx]));
}
Value_Type &operator[](Key_Unsigned_Type key) noexcept
{
return insert(key,Value_Type())->val();
}
bool if_is_in(const Key_Unsigned_Type key) const noexcept
{
uint key_moded(key%RANGE);
for(uint i(h[key_moded]);i;i=node[i].ne)
{
if(node[i].key()==key)
return true;
}
return false;
}
uint count(const Key_Unsigned_Type key) const noexcept
{
return if_is_in(key);
}
bool empty() const noexcept
{
return !idx;
}
uint size() const noexcept
{
return idx;
}
void clear() noexcept
{
memset(h,0,sizeof(h));
idx=0U;
}
void clear_existent_element() noexcept
{
while(idx)
{
h[node[idx].key()%RANGE]=0U;
--idx;
}
}
};火车头
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("Ofast","inline","-ffast-math")