hdu2609How many 最小表示法
来源:互联网 发布:微群控营销软件 编辑:程序博客网 时间:2024/06/15 17:13
//n(n<=10000)个字符串,字符串的长度l<=100//问这n个字符串中有多少不同得字符串//两个字符串相同只要其循环同构//先求出每个字符串的最小表示法//用map存下就行#include<cstdio>#include<cstring>#include<iostream>#include<map>using namespace std ;const int maxn = 1e4+10 ;map<string , int> ma ;string str ;int get_pos(int n){ int i = 0 ; int j = 1 ; int len = str.length() ; while(j < n) { if(str[i] > str[j]) i = j , j++ ; else if(str[i]<str[j]) j++ ; else { int k = 0 ; while(str[i+k] == str[j+k] && j+k < len) k++ ; if(str[i+k] > str[j+k]) i = i+k; else j++ ; } } return min(i , j) ;}int main(){ std::ios_base::sync_with_stdio(false); int n ; while(cin>>n) { ma.clear() ; int ans = 0 ; while(n--) { cin>>str ; int len = str.length() ; str += str ; int pos = get_pos(len) ; string p = "" ; for(int i = 0;i < len;i++) p += str[i+pos] ; if(ma[p] == 0) ma[p] = ++ans ; } cout<<ans<<endl ; } return 0 ;}
0 0
- hdu2609How many 最小表示法
- hdu2609How many
- hdu2609How many
- HDU2609How many
- hdu2609 How many (最小表示法)
- How many-字典树+最小表示法
- hdu 2609 How many(最小表示法)
- [最小表示法] hdu 2609 How many
- [最小表示法] HDU 2609 How many
- HDU - 2609 How many(最小表示法)
- HDU 2609 How many(最小表示法)
- HDU-2609 How many (最小表示法)
- HDU 2609 How many [最小表示法]
- 最小表示法+hash hdu2609 How many
- 【最小表示法】HDU2069How many【模板】
- HDU2609 How many(最小表示法)
- HDOJ 2609 How many (最小表示法)
- hdu 2609 How many(最小表示法)
- Django学习之manage.py使用
- LightOJ - 1017 Brush (III)
- 编写内核模块输出代码段的地址空间
- Android中显示GIF动画
- LeetCode 102: Binary Tree Level Order Traversal
- hdu2609How many 最小表示法
- Xcode如何请求网络并从网络上获得资源
- HDU 3074 Multiply game
- C++从零实现BP神经网络
- 返回值修改input值 jquery
- HDU-1029 Ignatius and the Princess IV
- 适配器设计模式
- LightOJ - 1018 Brush (IV)(状态压缩DP)
- 月薪3万的程序员都避开了哪些坑