当前位置:网站首页>[ybtoj advanced training guidance] class roll call [string hash]
[ybtoj advanced training guidance] class roll call [string hash]
2022-06-28 09:14:00 【VL——MOESR】
Ideas :
Direct string hash
c o d e code code
#pragma GCC optimize(3)// Don't mind
#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("-fwhole-program")
#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("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#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 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("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
using namespace std;
int mod=133331;
int n;
struct node
{
bool x;
string ss;
}ha[133332];
inline int hash_(string s)
{
register unsigned long long tmp=0;
register int len=s.size();
for(register int i=len-1; i>-1; --i)
tmp=(tmp*131)^s[i];
tmp%=mod;
register int tmp1=tmp;
while(ha[tmp].ss!=s&&ha[tmp].ss!="")
{
++tmp;
if(tmp>=mod)
tmp=0;
}
if(ha[tmp].ss!=s)
return 0;
else
{
register int flag;
if(!ha[tmp].x)
{
ha[tmp].x=1;
return 1;
}
else return 2;
ha[tmp].x=1;
}
}
int main()
{
scanf("%d ", &n);
for(register int i=1; i<=n; ++i)
{
register string s;
getline(cin, s);
register unsigned long long tmp=0;
register int len=s.size();
for(register int i=len-1; i>-1; --i)
tmp=(tmp*131)^s[i];
tmp%=mod;
register int tmp1=tmp;
while(ha[tmp].ss!="")
++tmp;
ha[tmp].ss=s;
}
register int q;
scanf("%d ", &q);
while(q--)
{
register string s;
getline(cin, s);
if(hash_(s)==1)
printf("OK\n");
else if(hash_(s)==2)
printf("REPEAT\n");
else printf("WRONG\n");
}
return 0;
}
( About the fact that he was stuck for half an hour )
边栏推荐
- Zhejiang energy online monitoring and management system
- STL - inverter
- Application of energy management system in iron and steel enterprises
- Basic operation of PMP from applying for the exam to obtaining the certificate, a must see for understanding PMP
- 1182: group photo effect
- Is it safe for CICC fortune to open an account? How much do you charge?
- Edit the live broadcast source code with me. How to write the live broadcast app code
- 1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定
- Maintenance and protection of common faults of asynchronous motor
- Discussion on the improvement and application of the prepayment system in the management of electricity charge and price
猜你喜欢
spark的资源调度和任务调度
硬盘基本知识(磁头、磁道、扇区、柱面)
SQL 优化经历:从 30248秒到 0.001秒的经历
Common tools for interface testing --postman
图解MySQL的binlog、redo log和undo log
Apiccloud, together with 360 Tianyu, helps enterprises keep the "first pass" of APP security
Basic knowledge of hard disk (head, track, sector, cylinder)
Decision table method for basic content learning of software testing (2)
Construire le premier réseau neuronal avec pytorch et optimiser
1182:合影效果
随机推荐
批量修改表和表中字段排序规则
Implementation of single sign on
The private attribute of this class can be used directly? New() in use!!!
Fire fighting work and measures in Higher Vocational Colleges
DEJA_ Vu3d - 051 of cesium function set - perfect realization of terrain excavation
Redis5.0 slot migration, free play (single machine migration cluster)
Automatic conversion - interview questions
Is it safe for CICC fortune to open an account? How much do you charge?
Three body attack (three-dimensional split plus two points)
静态代码块永远先执行? 格局小了!!!
Why does select * lead to low query efficiency?
Ffmpeg streaming fails to update header with correct duration
spark的资源调度和任务调度
Postman interface test
A - Bi-shoe and Phi-shoe
Basic operation of PMP from applying for the exam to obtaining the certificate, a must see for understanding PMP
STL - inverter
Quickly understand JVM structure and working principle
Decision table method for basic content learning of software testing (2)
Edit the live broadcast source code with me. How to write the live broadcast app code