#13,#14,#17~#21全部RE
查看原帖
#13,#14,#17~#21全部RE
757711
User757711楼主2023/8/24 09:49
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,int>vis;
bool check(string n1,char c1,string n2,char c2,string n3,char c3,string n4,char c4,string n5)
{
	if(n1[0]=='0'&&n1.size()!=1||n2[0]=='0'&&n2.size()!=1||n3[0]=='0'&&n3.size()!=1||n4[0]=='0'&&n4.size()!=1||n5[0]=='0'&&n5.size()!=1)
	{
		return 0;
	}
	if(c1!='.'||c2!='.'||c3!='.'||c4!=':')
	{
		return 0;
	}
	if(stoi(n1)<0||stoi(n1)>255||stoi(n2)<0||stoi(n2)>255||stoi(n3)<0||stoi(n3)>255||stoi(n4)<0||stoi(n4)>255||stoi(n5)<0||stoi(n5)>65535)
	{
		return 0;
	}
	return 1;
}
int main()
{
	//freopen("network3.in","r",stdin);
	//freopen("network3.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int p=0;
		string op;
		cin>>op;
		string s;
		cin>>s;
		char c1,c2,c3,c4;
		string n1,n2,n3,n4,n5;
		while(s[p]>='0'&&s[p]<='9')
		{
			n1+=s[p];
			p++;
		}
		c1=s[p];
		p++;
		while(s[p]>='0'&&s[p]<='9')
		{
			n2+=s[p];
			p++;
		}
		c2=s[p];
	    p++;
		while(s[p]>='0'&&s[p]<='9')
		{
			n3+=s[p];
			p++;
		}
		c3=s[p];
		p++;
		while(s[p]>='0'&&s[p]<='9')
		{
			n4+=s[p];
			p++;
		}
		c4=s[p];
		p++;
		while(s[p]>='0'&&s[p]<='9')
		{
			n5+=s[p];
			p++;
		}
		if(op=="Server")
		{
			if(!check(n1,c1,n2,c2,n3,c3,n4,c4,n5))
			{
				cout<<"ERR\n";
			}
			else
			{
				if(vis[s])
				{
					cout<<"FAIL\n";
				}
				else
				{
					cout<<"OK\n";
					vis[s]=i;
				}
			}
		}
		else
		{
			if(!check(n1,c1,n2,c2,n3,c3,n4,c4,n5))
			{
				cout<<"ERR\n";
			}
			else
			{
				if(!vis[s])
				{
					cout<<"FAIL\n";
				}
				else
				{
					cout<<vis[s]<<endl;
				}
			}
		}
	}
	return 0;
}
2023/8/24 09:49
加载中...