codeforces 448 B. Suffix Structures
来源:互联网 发布:怎样进入上层社会 知乎 编辑:程序博客网 时间:2024/06/06 03:52
题目链接:http://codeforces.com/contest/448/problem/B
题目大意:已知字符串a,b,要把a转换成b。如需删除输出automaton,如需交换输出array,都需要输出both,不可能成功输出need tree。
提示:用两个数组记一下26个字母的个数,在比较字母个数的大小,也就是先找need tree的时候
#include <iostream>#include <cstring>#include <cstdio>using namespace std;char a[105];char b[105];int main(){ int suma[26]={0}; int sumb[26]={0}; cin>>a>>b; int lena=strlen(a); int lenb=strlen(b); for(int i=0; i<lena; i++) suma[a[i]-'a']++; for(int i=0; i<lenb; i++) sumb[b[i]-'a']++; int arr=0; int aut=0; int f=0; for(int i=0; i<26; i++) { if(suma[i] < sumb[i]) { puts("need tree"); f=1; break; } if(suma[i]>sumb[i]) aut=1; } if(f) return 0; int pos=0; for(int i=0; i<lenb; i++) { int flag=0; for(int j=pos; j<lena; j++) { if(a[j] == b[i]) { pos=j+1; flag=1; break; } } if(flag == 0) { arr=1; break; } } if(arr == 1 && aut == 1) puts("both"); else if(arr == 1) puts("array"); else puts("automaton"); return 0;}
0 0
- Codeforces 448B. Suffix Structures
- Codeforces 448B Suffix Structures
- CodeForces 448-B. Suffix Structures
- CodeForces 448B Suffix Structures
- codeforces 448 B. Suffix Structures
- codeforces B. Suffix Structures
- codeforces Div.2 B.Suffix Structures
- Codeforces Div. 2 #256-B. Suffix Structures
- Codeforces Round #256 (Div. 2) B (448B) Suffix Structures
- Codeforces Suffix Structures
- B. Suffix Structures
- B. Suffix Structures
- Codeforces Round #256 (Div. 2) B. Suffix Structures
- Codeforces Round #256 (Div. 2) #B Suffix Structures
- Codeforces Round #256 (Div. 2) B. Suffix Structures
- Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)
- Codeforces Round #256 (Div. 2) B. Suffix Structures
- Codeforces Round #256 (Div. 2) B. Suffix Structures (乱搞)
- poj 2676 Sudoku (基础DFS)
- maven依赖关系中Scope的作用
- iOS开发系列--视图切换
- What does it mean to write `static void * ptr = &ptr` in objective-c?
- 数据类型和运算符(二)
- codeforces 448 B. Suffix Structures
- what happened while start nova compute service
- 面试题3:替换空格和清除空格
- 黑马day16 jquery&基本过滤器
- String类的编写
- CSS布局之各种居中
- NAT/Route/Tunnel三种模式实现代码简介
- 棋盘问题
- Ural 1557 1557. Network Attack