#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e6+5;
ll n;
string op,ad;
map<string,int> mp;
stringstream s_in;
bool check(string s)
{
ll a,b,c,d,e;
int t=sscanf(s.c_str(),"%lld.%lld.%lld.%lld:%lld",a,b,c,d,e);
if (t!=5) return 0;
else if (a>255||b>255||c>255||d>255||e>65535) return 0;
s_in<<a<<"."<<b<<"."<<c"."<<d<<":"<<e;
if (s_in.str()!=s) return 0;
return 1;
}
int main()
{
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>op>>ad;
if (!check(ad))
{
cout<<"ERR"<<endl;
continue;
}
if (op=="Server")
{
if (!mp[ad])
{
cout<<"OK"<<endl;
mp[ad]=i;
}
else cout<<"FAIL"<<endl;
}
else
{
if (!mp.count(ad)) cout<<"FAIL"<<endl;
else cout<<mp[ad]<<endl;
}
}
return 0;
}
本地编译错误
错误信息:[Error] expected ';' before string constant