| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
帮忙看看我做的错在哪????#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
string ch;
vector<vector<int> > m;
int n,h=0,max=0;
cin>>n;
if(n>50000 || n<3) exit(1);
cin>>ch;
if(ch.size()!=n) exit(1);
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(ch[i]==ch[j]){
vector<int> temp(2,1);
for(int k=i+1;k<=(i+j)/2;k++)
if(ch[k]==ch[j-(k-i)] && k!=j-(k-i)) temp.front()++;
temp.back()=j-i+1;
m.push_back(temp);
}
}
}
for(unsigned int i=0;i<m.size();i++){
if(max<m[i][0]){
max=m[i][0];
h=m[i][1];
}
}
if(h%2==0) cout<<n-2*max<<endl;
else cout<<n-2*max-1<<endl;
system("pause");
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator