题解 P2580 【于是他错误的点名开始了】
哎 虽然是
一开始模了
但这又怎能阻挡我的脚步?于是同时模了数据有待加强
代码精简 轻松易读
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<set>
template<typename _sp>
inline void qread(_sp &_x){
char _ch=getchar(),_lst=' ';
while(_ch<'0'||_ch>'9') _lst=_ch,_ch=getchar();
while(_ch>='0'&&_ch<='9') _x=(_x<<3)+(_x<<1)+(_ch^48),_ch=getchar();
if(_lst=='-') _x=-_x;
}
template<typename _sp>
inline _sp mmax(_sp __a,_sp __b){
return __a>__b?__a:__b;
}
template<typename _sp>
inline _sp mmin(_sp __a,_sp __b){
return __a<__b?__a:__b;
}
template<typename _sp>
inline _sp mabs(_sp __x){
return __x>0?__x:(-__x);
}
template<typename _sp>
inline void mswap(_sp &__a,_sp &__b){
_sp __t=__a;__a=__b;__b=__t;
}
template<typename _sp>
inline _sp mlowbit(_sp __x){
return __x&(-__x);
}
const long long LINF=0x3f3f3f3f3f3f3f3fll;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const int Mod1=10000009;
const int Mod2=10000007;
int n,m;
std::string s[10005];
std::set<int>a1,b1,a2,b2;
inline int hash1(std::string s){
int base=131,len=s.length();
long long tmp=0;
for(register int i=0;i<len;i++) tmp=(1ll*tmp*base+s[i])%Mod1;
return tmp;
}
inline int hash2(std::string s){
int base=131,len=s.length();
long long tmp=0;
for(register int i=0;i<len;i++) tmp=(1ll*tmp*base+s[i])%Mod2;
return tmp;
}
int main(){
qread(n);
for(register int i=1;i<=n;i++) std::cin>>s[i];
for(register int i=1;i<=n;i++){
a1.insert(hash1(s[i]));
a2.insert(hash2(s[i]));
}
qread(m);
for(register int i=1;i<=m;i++){
std::string c;
std::cin>>c;
int x1=hash1(c),x2=hash2(c);
if(b1.count(x1)&&b2.count(x2)) puts("REPEAT");
else if(a1.count(x1)&&a2.count(x2)){
puts("OK");
b1.insert(x1);
b2.insert(x2);
}
else puts("WRONG");
}
return 0;
}
码风太丑不喜勿喷(