构造
来源:互联网 发布:使命召唤ol流畅优化 编辑:程序博客网 时间:2024/04/30 09:08
- 因为26个字母都会出现,所以只有2个字符是重复的,而只要这两个相同的字符不连在一起出现就有解。
- 写起来有点麻烦
不要用 l(小写L) 做变量名!!!
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vector>#include <queue>#include <string>using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const LL mod=1e9+7;const double eps=1e-8;const int maxn=300005;string s;int a[30];char mp[3][20];void opt(){ for(int i=1;i<=2;++i){ for(int j=1;j<=13;++j){ printf("%c",mp[i][j]); } printf("\n"); }}int main(){ while(cin>>s){ memset(a,-1,sizeof(a)); bool fl=1; int tmp,i; for(i=0;i<27;++i){ tmp=s[i]-'A'; if(a[tmp]==-1)a[tmp]=i; else{ if(i-1==a[tmp]){fl=0;} break; } } int q=a[tmp],p=i; s.erase(s.begin()+p); if(!fl)printf("Impossible\n"); else{ int l=(p-q-1)/2; int qq=q,pp=q+1; for(int i=l;i>0;--i){ mp[1][i]=s[pp++]; } for(int i=1;pp<26&&i<=13;++i){ mp[2][i]=s[pp++]; } for(int i=13;pp<26;--i){ mp[1][i]=s[pp++]; } for(int i=l+1;i<=13&&qq>=0;++i){ mp[1][i]=s[qq--]; } for(int i=13;i>0&&qq>=0;--i){ mp[2][i]=s[qq--]; } opt(); } }}
阅读全文
0 0
- 构造
- 构造
- 构造
- 构造
- 构造
- 构造
- 构造、拷贝构造、析构
- 构造器(构造方法)
- 构造、拷贝构造、赋值
- 构造方法/构造器
- 拷贝构造 赋值构造
- 构造中调用构造
- 构造方法 构造器 构造函数
- 构造解决方案
- 构造函数
- 构造器
- 分组构造
- 替换构造
- 入门树状数组(左边比x小的个数)
- python学习(十)----matplotlib模块相关函数
- 17/8/18
- hdu3065
- Find the hotel(HDU-3193) (RMQ)
- 构造
- 一步一步学多线程-Timer
- HDU 6125 Free from square
- 文件解析漏洞总结-IIS
- 解决 deployment is out of dete due to changes in the underlying project contents youll need to
- 比赛心得
- 指针学习
- hdu2846
- 算法学习之旅,中级篇(1)-–选择排序