| ||||||||||
| 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 <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <deque>
#include <string>
using namespace std;
set <string> myset;
deque <string> mydeq;
pair< set<string>::iterator, bool > sok;
int main()
{
ifstream cin("a.txt");
string srep[100][2];
basic_string <char>::size_type inda, indb;
string in;
cin>>in;
in.erase(in.begin());
in.erase(in.end()-1);
myset.insert(in);
mydeq.push_back(in);
int n=0,re=0,end=0;
string ga;
while (cin>>ga)
{
inda=ga.find("\"->");
srep[n][0].assign(ga.begin()+1,inda-1);
srep[n][1].assign(ga.begin()+inda+4,ga.end()-1);
if(srep[n][1].find(srep[n][0])!=-1){//npos
cout<<"Too many." <<endl;
return 0;
}
n++;
}
int i;
while(1)
{
char *a=(char *)mydeq.front().c_str();
for(i=0;i<n;i++)
{
char *in=0,*tem=a;
char *b=(char *)srep[i][0].c_str();
string c=srep[i][1];
while(1)
{
in=strstr(tem,b);
if(in!=0)
{
string ins(a,in-a);
ins=ins+c;
ins.append(in+strlen(b));
sok=myset.insert(ins);
if(sok.second)
mydeq.push_back(ins);
}else{
break;
}
tem=in+1;
}
}
mydeq.pop_front();
if(mydeq.empty()||1000<myset.size())
break;
}
if(myset.size()>1000)
cout<<"Too many." <<endl;
else
cout<<myset.size()<<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator