这怎么一直是0分
查看原帖
这怎么一直是0分
891545
Shuo_Wang楼主2023/10/2 16:16
include <bits/stdc++.h>
using namespace std;
int ji=0,sum[10001];
	string aa[1001];
bool cc(char m[]){
	int a,b,c,d,e;
	a=b=c=d=e=-1;
	int ee=sscanf(m,"%d.%d.%d.%d:%d",&a,&b,&c,&d,&e);
	if(ee!=5) return 0;else{
	if(a<0||a>255||b<0||b>255||c<0||c>255||d<0||d>255||e<0||e>65535)
	return 0;
	else return 1;
	}
}
string w,a;
int main(){
    int n;cin>>n;
	for(int i=1;i<=n;i++){
    cin>>w;cin>>a;
	if(w[0]=='S'){
		char q[1001];
		for(int t=0;t<a.size();t++){
			q[t]=a[t];
		}
		if(cc(q)==1){
			bool f=1;
			for(int k=0;k<=n;k++){
				if(aa[k]==a) {
					f=0;
					break;
				}
			}
			if(f==0){
				cout<<"FAIL"<<endl;
			}else { aa[ji]=a;sum[ji]=i;
			ji++;
			cout<<"OK"<<endl;}
		}else{
			cout<<"ERR"<<endl;
		}
	}else{
		char q[1001];
		for(int t=0;t<a.size();t++){
			q[t]=a[t];
		}
	if(cc(q)==1){
		bool f2=0;
		for(int w=0;w<=n;w++){
			if(a==aa[w]){
			cout<<sum[w]<<endl;
			f2=1;
			break;}
		}
		if(f2==0) cout<<"FAIL"<<endl;
	}	
	else{
		cout<<"ERR"<<endl;
	}
	}
	}
	return 0;
}
2023/10/2 16:16
加载中...