全wa 求助
查看原帖
全wa 求助
712087
fennudexiaozhiyin楼主2023/7/7 11:09
#include <bits/stdc++.h>
using namespace std;
long long n;
string op,ad;
string lcx[100009];
bool t;
bool a[1000009];
struct all{
	string op,ad;
}q[100009];
bool c(string x){
	int dn=0,mn=0;
	int j=0,k=0;
	int y[5];
	string a,b,c,d,e;
	int aa,bb,cc,dd,ee;
	for(int i=0;i<x.size();i++){
		if(x[i]=='.'){
			dn++;
			y[j]=i;
			j++;
		} 
		if(x[i]==':'){
			mn++;	
			k=i;
		}
	}
	if(dn!=3|| mn!=1){
		
		return 0;
	}
	else {
		//cout<<1;
		a=x.substr(0,y[0]);
		b=x.substr(y[0],y[1]-y[0]-1);
		c=x.substr(y[1],y[2]-y[1]-1);
		d=x.substr(y[2],y[3]-y[2]-1);
		e=x.substr(k,x.size()-1-k);
		
		if(a==" " || b==" " || c==" " || d==" " || e==" ") return 0;
		
		if(a[0]==0 && a.size()>1) return 0;
		if(b[0]==0 && b.size()>1) return 0;
		if(c[0]==0 && c.size()>1) return 0;
		if(d[0]==0 && d.size()>1) return 0;
		if(e[0]==0 && e.size()>1) return 0;
		aa=atoi(a.c_str());
		bb=atoi(b.c_str());
		cc=atoi(c.c_str());
		dd=atoi(d.c_str());
		ee=atoi(e.c_str());
		cout<<aa<<" "<<bb<<" "<<cc<<" "<<dd<<" "<<ee;
		if(aa<0||aa>255) return 0;
		if(bb<0||bb>255) return 0;
		if(cc<0||cc>255) return 0;
		if(dd<0||dd>255) return 0;
		if(ee<0||ee>65535) return 0;
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>q[i].op>>q[i].ad;
	}
	for(int i=0;i<n;i++){
		if(c(q[i].ad)==0){
			lcx[i]="ERR";
		}
		else {
			if(q[i].op=="Server") {
				t=0;
				for(int j=i;j<n;j++){
					if(q[i].op=="Client" && q[i].ad==q[j].ad && a[j]==0){
						lcx[i]="OK";
						lcx[j]=i;
						a[j]=1;
						t=1;
					}
				} 
				if(t==0){
					lcx[i]="FAIL";
				}
			} 	
		}
		
	}
	for(int i=0;i<n;i++){
		cout<<lcx[i]<<endl;
	}
    return 0;
}
2023/7/7 11:09
加载中...