PKU 3510 A Tale from the Dark Side of the Moon

http://poj.org/problem?id=3510
いろいろとひどいような気がする問題。

一発でAC出来る人は相当すごいと思います。
Discussを見て直し直しやりました。

main(){
  string temp;
  while(getline(cin,temp)){
    if(temp.substr(0,3)=="EOF")break;
    bool end=false;
    if(temp.find("EOF")!=string::npos){
      end=true;
      temp=temp.substr(0,temp.find("EOF"));
    }
    string in=temp;

    int pos=1;
    while((pos=in.find("dd"))!=string::npos){
      in.replace(pos,2,"p");
    }
    pos=0;
    while((pos=in.find("ei",pos))!=string::npos){
      if(pos && in[pos-1]=='c')++pos;
      else in.replace(pos,2,"ie"),pos+=2;
    }
    while((pos=in.find("pink"))!=string::npos)in.replace(pos,4,"floyd");
    

    temp=in;
    in="";
    rep(i,SZ(temp))
      if(islower(temp[i]) || temp[i]==' ')in+=temp[i];    
    
    cout<<in<<endl;
    if(end)break;
  }
}