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

如何能够在这种题上WA了N次后找到一个乐于助人的大牛?

Posted by AllwaysDead at 2009-02-21 16:45:57 on Problem 3510
我不懂......
#include <cstdio>
using namespace std;
class Comparer{
private:
        int id;
        char chs[10];
public:
       Comparer(char *a){
                     chs[0]=a[0];
                     for (int i=1;a[i-1];i++)chs[i]=a[i];
                     id=0;
       }
       void putch(char a){
            if (chs[id]==0)id=0;
            if (chs[id]==a)id++;
            else id=0;
       }
       int compared(){return chs[id]==0;}
};
class Outputpool{
private:
        int id,l;
        char chs[10];
public:
       Outputpool(){id=l=0;}
       void putch(char a){
            if (l==10){
               putchar(chs[id]);
               id++;id%=10;
               chs[(id+9)%10]=a;
            }
            else{
                 chs[(id+l)%10]=a;
                 l++;
            }
       }
       void putch(char *a){for (int i=0;a[i];i++)putch(a[i]);}
       void rollback(int a){
            if (l>=a)l-=a;
       }
       void empty(){
            for (int i=0;i<l;i++)putchar(chs[(id+i)%10]);
       }
};
int main()
{
    char a;
    Comparer cDD("dd"),cEOF("EOF"),cPink("pink"),cEI("ei");
    Outputpool outP;
    while ((a=getchar())!=EOF){
          cDD.putch(a);cEOF.putch(a);cPink.putch(a);cEI.putch(a);
          if (cEOF.compared())break;
          if (cDD.compared()){
             outP.rollback(1);
             outP.putch('p');
          }else if (cEI.compared()){
                outP.rollback(1);
                outP.putch("ie");
          }else if (cPink.compared()){
               outP.rollback(3);
               outP.putch("floyd");
          }else if (a>='a' && a<='z' || a==' ' || a==10)outP.putch(a);
    }
    outP.empty();
    getchar();getchar();
    return 0;
}


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