打完不知道哪里错了
#include<bits/stdc++.h>
using namespace std;
int p[1050][5],s[65536][5];
map<string,int> pr;
int main()
{
// freopen("network.in","r",stdin);
// freopen("network.out","w",stdout);
int n;
cin>>n;
for(int j=1;j<=n;j++)
{
string op;
cin>>op;
int k=0;
if(op[0]=='S')k=1;
if(op[0]=='C')k=-1;//k用来判断连接与被连接的电脑
cin>>op;
int t=0,r=0;
for(int i=0;i<op.size();i++)
{
int x=0;
if(op[i]>='0' and op[i]<='9')
{
if(op[i+1]<='9' and op[i+1]>='0' and op[i]=='0')
{
cout<<"ERR"<<endl;
r=1;
break;
}
//这里判断如果第一个数字为1,那么判断下一个是不是数字,是数字输出err
int jj=i;
while(op[jj]>='0' and op[jj]<='9')
{
x=x*10+op[jj]-'0';
jj++;
}
//把数字求出来
i=jj-1;//把枚举的指针更新
if((x<=255 and x>=0) or (t==4 and x<=65535 and x>=0))p[j][t++]=x;
else
{
r=1;
cout<<"ERR"<<endl;
break;
}//判断是否大于界值
}
else
{ //不是数字就判断符号
if((t<=3 and op[i]=='.') or (t==4 and op[i]==':'));
else
{
r=1;
cout<<"ERR"<<endl;
break;
}
}
}
if(r==1)continue;
if(k==1)
{
if(pr[op])
{
puts("FAIL");
}
else
{
pr[op]=j;
puts("OK");
}
}
if(k==-1)
{
if(pr[op])
{
cout<<pr[op]<<endl;
}
else
{
puts("FAIL");
}
}
}
}