网络赛前10奖励计蒜客的本子或鼠标垫(外校也可以来现场领取)
Xidian Online Judge WebBoard
[ New Thread ]
Problem 1012 >> 求帮忙看看什么数据过不了啊。。
13010520016 @ 2015-04-26 21:55:48
[ Quote ] [ Edit ] [ Delete ] 1#
#include<iostream>
using namespace std;
int confirm(char s[],int l,int r){
int i;
if (l<0)return 0;
for (i=0;i<r-l;i++)
if (s[l-i]!=s[r-i])break;
if (i!=r-l)return 0;
else return (1+confirm(s,2*l-r,l));
}
int main(){
char s[400001];
int ans;
int len;
int key;
int cnt,cnt1;;
while (cin.getline(s,400000)){
len=0;
cnt=1;
cnt1=0;
while (s[len]!='\0')len++;
ans=len;
key=len-2;
while (key!=0){
if (s[key]==s[len-1]){
cnt1=confirm(s,key,len-1);
if(cnt1>=cnt)
{ans=key+1;cnt=cnt1;}
}
key--;
}
if (ans==len) cout<<-1<<endl;
else {while (ans<len)
{cout<<s[ans];ans++;}
cout<<" "<<cnt+1<<endl;
}
}
return 0;
}
//思考良久,觉得应该没有数据会卡住。。无奈真的答案错误- -!
xry111 @ 2015-04-26 23:10:49
[ Quote ] [ Edit ] [ Delete ] 2#
400000个随机字符,这程序没任何输出。
[Top] [Previous Page] [Next Page]
Anything about the Problems, Please Contact Admin:admin
All Copyright Reserved 2010-2014 Xidian ACM Online Judge TEAM
GPL2.0 2003-2014 HUSTOJ Project TEAM