Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:忘记写return 0,WA了半天!FT!黑莓日

Posted by leichangcheng at 2011-04-19 23:31:52 on Problem 1226
In Reply To:忘记写return 0,WA了半天!FT!黑莓日 Posted by:orlando22 at 2009-03-23 12:39:53
> 该死的代码如下,tmd,害我用c++,c把strrev,strncpy都自己写了个遍!伤心的很,20次
> 提交花在这种题上,真不值!
> #include <iostream>
> #include <string>
> #include <fstream>
> 
> using namespace std;
> const int MAX=102;
> string str[MAX];
> char t[MAX];
> 
> #define fbase
> int main()
> {
>     #ifdef fbase
>     ifstream in("input.txt");
>     if(!in) return EXIT_FAILURE;
>     cin.rdbuf(in.rdbuf());
>     #endif
> 
>     //implementation
>     int n,m,len,i,j,k;bool all;
>     cin>>n;
>     while(n--){
>         cin>>m;
>         len=MAX+2;//minmal of string
>         string strMin;
>         for(i=0; i<m; i++){
>             cin>>t,str[i]=t;
>             if(str[i].size()<len) strMin=str[i],len=str[i].size();
>         }
>         //compare each string with strMin
>         int iMinslen=len;len=0;
>         for(k=iMinslen;k>0;k--){
>             all=false;//all supposed=true
>             for(j=0;j<=iMinslen-k;j++){//k is len of template string
>                 string b=strMin.substr(j,k);//how to implement?
>                 strncpy(t, b.c_str(), k),t[k]='\0';
>                 for(char *s=t,*e=t+k-1;s<=e;s++,e--){
>                     char tmp=*s;*s=*e;*e=tmp;
>                 }
>                 string rb=t;
>                 all=true;
>                 for(i=0;i<m;i++){
>                     if(str[i].find(b)==string::npos&&str[i].find(rb)==string::npos){
>                         all=false;break;//for both which can't find substring
>                     }
>                 }
>                 if(all){len=k; break;}
>             }
>             if(all) break;
>         }
>         cout<<len<<endl;
>     }
> 
>     #ifdef fbase
>     in.close();
>     #endif
>     return 0;//我恨你!
> }
> #undef fbase

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator