博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVALive 4423 String LD 暴力
阅读量:5902 次
发布时间:2019-06-19

本文共 1999 字,大约阅读时间需要 6 分钟。

A - String LD
Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu
Submit

Description

Stringld(left delete) is a function that gets a string and deletes its leftmost character (for instance Stringld(``acm") returns ``cm").

You are given a list of distinct words, and at each step, we apply stringld on every word in the list. Write a program that determines the number of steps that can be applied until at least one of the conditions become true:

 

  1. A word becomes empty string, or
  2. a duplicate word is generated.

For example, having the list of words aab, abac, and caac, applying the function on the input for the first time results in ab, bac, and aac. For the second time, we get b, ac, and ac. Since in the second step, we have two ac strings, the condition 2 is true, and the output of your program should be 1. Note that we do not count the last step that has resulted in duplicate string. More examples are found in the sample input and output section.

Input

There are multiple test cases in the input. The first line of each test case is n(1$ \le$n$ \le$100) , the number of words.

Each of the next n lines contains a string of at most 100 lower case characters.

The input terminates with a line containing `0'.

Output

For each test case, write a single line containing the maximum number of stringld we can call.

Sample Input

4 aaba aaca baabcd dcba 3 aaa bbbb ccccc 0

Sample Output

12
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;using namespace std;//freopen("D.in","r",stdin);//freopen("D.out","w",stdout);#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)#define maxn 100001const int inf=0x7fffffff; //无限大//string &erase(int pos = 0, int n = npos);//删除pos开始的n个字符,返回修改后的字符串string s[1001];int main(){ int n; while(cin>>n) { if(n==0) break; for(int i=0;i
>s[i]; int flag=0; int flag2=0; if(n!=1) while(1) { for(int i=0;i

 

转载地址:http://aykpx.baihongyu.com/

你可能感兴趣的文章
vue-validator(vue验证器)
查看>>
jQuery Ajax MVC 下拉框联动
查看>>
html
查看>>
c#创建文件夹
查看>>
Hibernate事务代码规范写法
查看>>
网络最大流问题算法小结 [转]
查看>>
面试之Java知识整理
查看>>
iOS推送消息报错误“Domain=NSCocoaErrorDomain Code=3000”的可能问题
查看>>
kvm-1
查看>>
hdu1045 Fire Net---二进制枚举子集
查看>>
leetcode 64. Minimum Path Sum
查看>>
textkit
查看>>
CentOS7+CDH5.14.0安装CDH错误排查: HiveServer2 该角色的进程已退出。该角色的预期状态为已启动...
查看>>
The Oregon Trail 俄勒冈之旅
查看>>
Excel VBA连接MySql 数据库获取数据
查看>>
Developing a Service Provider using Java API(Service Provider Interface)(转)
查看>>
BAE Flask UEditor 使用七牛云
查看>>
Bootstrap系列 -- 15. 下拉选择框select
查看>>
【转载】无限级分类的简单实例
查看>>
关于WinPE安装操作系统
查看>>