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 |
的确可以在杭电oj上AC,但在这里WA了!#include<stdio.h> #include<iostream> #include<string.h> #include<string> #define VOL 205 #define FOR(i, j, k) for(int i=j; i<k; i++) using namespace std; typedef long long LL; int num; string ccc[105]; int minlen ; int movelen, k; int mid_len, n; int test(string str1) { string str2(str1.rbegin(), str1.rend()); for(int i=1; i<=num; i++) { if(ccc[i].find(str1) == -1) { if(ccc[i].find(str2) == -1 ) return 0; } } return 1; } void solve() { for(int i=0; i<mid_len; i++) { for(int j=0; j<=mid_len-movelen; j++) { string mid_string1; mid_string1 = ccc[k].substr(j, movelen); if(test(mid_string1)) { cout<<movelen<<endl; return; } } movelen--; } cout<<"0"<<endl; return; } int main() { //freopen("D:\\CPPProgram\\ACM\\in.txt", "r", stdin); cin>>n; while (n--) { minlen = 110; cin>>num; for (int i=1; i<=num; i++) { cin>>ccc[i]; mid_len= ccc[i].length(); if(mid_len<minlen) { k = i; minlen = mid_len; movelen = minlen; } } solve(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator