HELPHELPHELP 0分 WA满江红
查看原帖
HELPHELPHELP 0分 WA满江红
708860
封禁用户楼主2022/10/5 13:03
0分程序

#include<iostream>
#include<cstdio>
using namespace std;
bool check(string s){
	char x[1145];
	int a=-114514,b=-114514,c=-114514,d=-114514,e=-114514;
	for(int i=0;i<s.length();i++){
		x[i]=s[i];
	}
	sscanf(x,"%d.%d.%d.%d:%d",&a,&b,&c,&d,&e);
	sprintf(x,"%d.%d.%d.%d:%d",a,b,c,d,e);
	if(x!=s){
		return false;
	}
	if(a>255 || b>255 || c>255 || d>255){
		return false;
	}
	if(a<0 || b<0 || c<0 || d<0){
		return false;
	}                    
	if(e>65535 || e<0){
		return false;
	}
	return true;
}
int main(){
	int n;
	bool f;
	scanf("%d",&n);
	string a[1145]={" "},s1,s2;
	for(int i=1;i<=n;i++){
		cin>>s1>>s2;
		f=true;
		if(check(s2)==false){
			cout<<"ERR"<<endl;
			f=false;
		}
		if(f==true){
			if(s1=="Server"){
				f=true;
				for(int j=1;j<i;j++){
					if(a[j]==s2){
						cout<<"FAIL"<<endl;
						f=false;
					break;
					}
				}
				if(f==true){
					cout<<"OK"<<endl;
					a[i]=s2;
				}
			}
			else{
				bool f=false;
				for(int j=1;j<i;j++){
					if(a[j]==s2){
						cout<<j<<endl;
						f=true;
						break;
					}
				}
				if(f==false){
					cout<<"FAIL"<<endl;
				}
			}
		}
	}
	return 0;
}
2022/10/5 13:03
加载中...