uva10602 - Editor Nottoobad
来源:互联网 发布:网络到internet有个x 编辑:程序博客网 时间:2024/05/22 17:25
大水题。。。
比较前缀,,,,,
代码如下:
#include <cstdio>#include <cstring>#define M 105char st[M][M];int path[M], fl[M];int get_result(int a, int b){ int len = strlen(st[a]); for(int i = 0; i < len; i++) if(st[a][i]!=st[b][i]) return i; return len;}int main (){ int t, n, ans, max; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i = 0; i < n; i++) scanf("%s",st[i]); ans = strlen(st[0]); path[0] = 0; memset(fl,0,sizeof(fl)); for(int i = 0; i < n; i++) { max = -1; for(int j = 1; i<n&&j < n; j++) { if(fl[j]) continue; int tt = get_result(path[i], j); if(max<tt) {path[i+1] = j; max = tt; } } fl[path[i+1]] = 1; if(i<n-1) ans += strlen(st[path[i+1]]) - max; } printf("%d\n",ans); for(int i = 0; i < n; i++) printf("%s\n",st[path[i]]); } return 0;}
- uva10602 - Editor Nottoobad
- [贪心]UVA10602 Editor Nottoobad
- uva10602 - Editor Nottoobad
- uva10602 Editor Nottobad
- UVa 10602 - Editor Nottoobad
- UVa 10602 - Editor Nottoobad
- uva 10602 - Editor Nottoobad
- UVA 10602 - Editor Nottoobad
- UVA 10602 - Editor Nottoobad
- 10602 - Editor Nottoobad
- UVaOJ10602 - Editor Nottoobad
- uva 10602 Editor Nottoobad
- UVA 10602 EDITOR NOTTOOBAD
- Editor Nottoobad-10602
- UVa 10602 - Editor Nottoobad
- EDITOR NOTTOOBAD uva+贪心
- UVA - 10602 Editor Nottoobad
- UVA - 10602 Editor Nottoobad
- Getting started with windbg - part II
- oracle数据库导入导出
- 重回Java开发-利用反射模拟Spring
- android权限大全
- Using WinDbg - Advanced commands
- uva10602 - Editor Nottoobad
- volatile在嵌入式开发中的作用
- Eclipse与github整合完整版
- Using WinDbg - Hunting Exceptions
- HDU-4535-吉哥系列故事——礼尚往来
- emacs gdb调试
- epoll 的实现原理
- 黑马程序员_day20_Map集合
- 【自己动手写数据结构】 -- 循环队列的表示与实现