?? usaco_prefix.cpp
字號:
/*
ID: wangyuc2
PROG: prefix
LANG: C++
*/
#include <fstream>
#include <iostream>
#include <memory>
#include <algorithm>
using namespace std;
ifstream fin("prefix.in");
ofstream fout("prefix.out");
int main()
{
char t[200][11];
char s[200005];
bool st[200005];
char s1[11];
char ch;
int i,j,k,p,m,n,end;
bool flag;
flag=false;
i=0;
memset(st,false,sizeof(st));
do{
fin>>t[i];
i++;
}while(strcmp(t[i-1],"."));
m=i-1; i=0; // the number of primitives;
while(!fin.eof())
{
fin>>ch;
if(ch<='Z' && ch>='A') {s[i]=ch;
i++;}
}
i--;
s[i]='\0';
// fout<<s;
end=0;
for(i=0;!flag && i<=end;i++)
{
if(i==0 || st[i]){
for(j=0;j<m;j++)
{
strncpy(s1,s+i,strlen(t[j]));
s1[strlen(t[j])]='\0';
if(!strcmp(t[j],s1))
{
st[i+strlen(t[j])]=true;
if(i+strlen(t[j])>end) end=i+strlen(t[j]);
}
}
}
}
fout<<end<<endl;
//system("PAUSE");
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -