最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

CodeforcesBetaRound#4(Div.2Only)C.Registrationsystem_html/css

来源:动视网 责编:小采 时间:2020-11-27 15:58:58
文档

CodeforcesBetaRound#4(Div.2Only)C.Registrationsystem_html/css

CodeforcesBetaRound#4(Div.2Only)C.Registrationsystem_html/css_WEB-ITnose:这个题感觉还不错,以前字典树写的是最顺手的,这几次比赛屡屡挂在字典树上也是有阴影了啊~~ 题目大意: 给出一些字符串,对每个字符串进行查询,若没出现过返回OK,若出现过就生成新字符串,格式为原字符串+数,数为这个字符串第几次重复出现。
推荐度:
导读CodeforcesBetaRound#4(Div.2Only)C.Registrationsystem_html/css_WEB-ITnose:这个题感觉还不错,以前字典树写的是最顺手的,这几次比赛屡屡挂在字典树上也是有阴影了啊~~ 题目大意: 给出一些字符串,对每个字符串进行查询,若没出现过返回OK,若出现过就生成新字符串,格式为原字符串+数,数为这个字符串第几次重复出现。


这个题感觉还不错,以前字典树写的是最顺手的,这几次比赛屡屡挂在字典树上也是有阴影了啊~~



题目大意:

给出一些字符串,对每个字符串进行查询,若没出现过返回OK,若出现过就生成新字符串,格式为原字符串+数,数为这个字符串第几次重复出现。



解题思路:

字典树,对于每个字符串的插入次数进行计数。



下面是代码:

#include #include #include #include #include #include #include #include #include #include #include #include #define eps 1e-10#define pi acos(-1.0)#define inf 107374182#define inf 1152921504606846976#define lc l,m,tr<<1#define rc m + 1,r,tr<<1|1#define zero(a) fabs(a) 0 ? (x) : -(x))#define clear1(A, X, SIZE) memset(A, X, sizeof(A[0]) * (min(SIZE,sizeof(A))))#define clearall(A, X) memset(A, X, sizeof(A))#define memcopy1(A , X, SIZE) memcpy(A , X ,sizeof(X[0])*(SIZE))#define memcopyall(A, X) memcpy(A , X ,sizeof(X))#define max( x, y ) ( ((x) > (y)) ? (x) : (y) )#define min( x, y ) ( ((x) < (y)) ? (x) : (y) )using namespace std;struct node{ int p; int num[26];}node[500000];char s[50];int cnt,len;int InsertString(int strp,int p){ if(strp==len) { node[p].p++; return node[p].p; } if(node[p].num[s[strp]-'a']==0) { node[p].num[s[strp]-'a']=cnt++; } return InsertString(strp+1,node[p].num[s[strp]-'a']);}int main(){ int n,temp; cnt=1; clearall(node,0); scanf("%d",&n); for(int i=0;i

文档

CodeforcesBetaRound#4(Div.2Only)C.Registrationsystem_html/css

CodeforcesBetaRound#4(Div.2Only)C.Registrationsystem_html/css_WEB-ITnose:这个题感觉还不错,以前字典树写的是最顺手的,这几次比赛屡屡挂在字典树上也是有阴影了啊~~ 题目大意: 给出一些字符串,对每个字符串进行查询,若没出现过返回OK,若出现过就生成新字符串,格式为原字符串+数,数为这个字符串第几次重复出现。
推荐度:
标签: it div round
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top