救救本蒟蒻吧qwq
查看原帖
救救本蒟蒻吧qwq
799373
diva233楼主2023/10/15 11:14

判断好像有问题。。。

#include <bits/stdc++.h>
#define s Server
#define c Client
#define pD q[i].a==q[j].a && q[i].b==q[j].b && q[i].c==q[j].c && q[i].d==q[j].d && q[i].e==q[j].e
using namespace std;

struct node{
	string op;
	int a,b,c,d,e,id;
	bool type,right;//0->S 1->C 
}q[1010];
char cHaR[10];

void id_cin(int i){
	cin >>q[i].a>>cHaR[1]>>q[i].b>>cHaR[2]>>q[i].c>>cHaR[3]>>q[i].d>>cHaR[4]>>q[i].e;
	if(q[i].a<=255 && q[i].b<=255 && q[i].c<=255 && q[i].d<=255 && q[i].e<=65535 && cHaR[1]=='.' && cHaR[2]=='.' && cHaR[3]=='.' && cHaR[4]==':'){
		q[i].right=true;
		return ;
	}
	q[i].right=false;
	cout <<"ERR"<<endl;
	return ;
}

int main(){
	//freopen("network.in","r",stdin);
	//freopen("network.out","w",stdout);
	int n;
	cin >>n;
	for(int i=1;i<=n;i++){
		cin >>q[i].op;
		q[i].id=i;
		if(q[i].op=="s"){
			q[i].type=0;
			id_cin(i);
			if(q[i].right==false) break;
			for(int j=1;j<=i;j++){
				if(pD && q[i].type==0 && q[j].type==0 && q[j].id!=i) {
					cout <<"FAIL"<<endl;
					break;
				}
				else {
					cout <<"OK"<<endl;
					break;
				}
			}
			//printf("q[i].right=%d\n",q[i].right);
			//cout <<q[i].a<<q[i].b<<q[i].c<<q[i].d<<q[i].e<<endl;
		}
		else{
			q[i].type=1;
			id_cin(i);
			if(q[i].right==false) break;
			for(int j=1;j<=i;j++){
				if(pD && q[i].type==1 &&q[j].type==0 && q[j].id!=i){
					cout <<q[j].id<<endl;
					break;
				}
				else{
					cout <<"FAIL"<<endl;
					break;
				}
			}
			//printf("q[i].right=%d\n",q[i].right);
			//cout <<q[i].a<<q[i].b<<q[i].c<<q[i].d<<q[i].e<<endl;
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
2023/10/15 11:14
加载中...