代码
2025-08-08 19:49:34
发布于:浙江
11阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
map<string,int>mp;
int getlen(int x){
int len=0;
if(x==0)return 1;
while(x){
x/=10;
len++;
}
return len;
}
bool check(string s){
string tmp="";
int num=0,cnt=0;
for(int i=0;i<s.size();i++){
if(s[i]>='0'&&s[i]<='9'){
num=num*10+s[i]-'0';
cnt++;
}
else {
if(cnt==0||cnt>=4||num>255||getlen(num)!=cnt){
return 0;
}
tmp+=s[i],num=cnt=0;
}
}
if(tmp=="...:"&&cnt>0&&cnt<6&&num<65535&&getlen(num)==cnt)
return 1;
else return 0;
}
int main(){
cin>>n;
string s,t;
for(int i=1;i<=n;i++){
cin>>s>>t;
if(!check(t)){
cout<<"ERR"<<endl;
continue;
}
if(s=="Server"){
if(mp[t]){
cout<<"FAIL"<<endl;
}
else {
cout<<"OK"<<endl;
mp[t]=i;
}
}
else {
if(mp[t]){
cout<<mp[t]<<endl;
}
else {
cout<<"FAIL"<<endl;
}
}
}
return 0;
}
这里空空如也
有帮助,赞一个