CH Round #57 - Story of the OI Class 凯撒密码
来源:互联网 发布:java 垃圾回收算法 编辑:程序博客网 时间:2024/06/06 01:53
相邻字符串hash具有唯一性
#include<cstdlib>#include<iostream>#include<cmath>#include<cstring>#include<cstdio>#include<string>#include<algorithm>using namespace std;const int N=1000005;const int M=27;int f[M][M];int n;int a[N];char b[N];void solve(){for (int i=1; i<=n; i++){char s[6];scanf("%s", s); int t=0;for (int j=0; j<4; j++){t=t*26+f[s[j]-'a'+1][s[j+1]-'a'+1];} a[t]=i; b[t]=s[0];}for (int i=1; i<=n; i++){char s[6];scanf("%s", s);int t=0;for (int j=0; j<4; j++){t=t*26+f[s[j]-'a'+1][s[j+1]-'a'+1];}printf("%d %d\n", a[t], f[s[0]-'a'+1][b[t]-'a'+1]);}}void init(){scanf("%d", &n);for (int i=1; i<=26; i++) for (int j=1; j<=26; j++) { if (j>=i) f[i][j]=j-i; else f[i][j]=26-i+j; }}int main(){init();solve();return 0;}
0 0
- CH Round #57 - Story of the OI Class 凯撒密码
- CH Round #57 - Story of the OI Class 查错
- The Story of today.
- THE STORY OF O
- The Story of Creating Enterprises
- the story of new oriental
- Outliers: The Story of Success
- The End-of-Line Story
- The story of a cow
- 凯撒密码
- 凯撒密码
- 凯撒密码
- 凯撒密码
- 凯撒密码
- 凯撒密码
- 凯撒密码
- 凯撒密码
- 凯撒密码
- 数据结构之链栈(参考整理严蔚敏数据结构)
- POJ 1321 棋盘问题
- SQLite学习手册(数据表和视图)
- 2440(ARM9)中Ucos移植相关
- Android - Studio Gradle下载缓慢的解决办法 (Mac)
- CH Round #57 - Story of the OI Class 凯撒密码
- Oracle存储过程中使用临时表
- 鸟哥Linux私房菜知识点总结0到2章
- The 2013 South America/Brazil Regional Contest 题解
- 《数据结构》实验三: 栈和队列实验
- Google Chrome下Flash Player Debug失效 - [Flex]
- 深入C#学习系列一:序列化(Serialize)、反序列化(Deserialize)
- ParticleEditor粒子编辑器
- POJ 2631 Roads in the North(树的直径)