0分求调
查看原帖
0分求调
1200401
wnqnld_llx楼主2024/7/15 19:57
#include<bits/stdc++.h>
using namespace std;
int n;
char op[100],ad[100];
map<string,int> mp;
bool check(char s[100]){
	int a,b,c,d,e;
	int t=sscanf(s,"%d.%d.%d.%d:%d",&a,&b,&c,&d,&e);
	if(t!=5){
		return 0;
	}
	char s2[100];
	sprintf(s2,"%d.%d.%d.%d:%d",a,b,c,d,e);
	int l=strlen(s);
	for(int i=0;i<l;i++){
		if(s[i]!=s2[i]) return 0;
	}
	return 1;
}
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>op>>ad;
		if(!check(ad)){
			cout<<"ERR"<<endl;
			continue;
		} 
		if(op=="Server"){
			if(mp[ad]){
				cout<<"FALL"<<endl;
			}
			else{
				cout<<"OK"<<endl;
				mp[ad]=i;
			}
		}
		else{
			if(mp[ad]){
				cout<<mp[ad]<<endl;
			}
			else{
				cout<<"FALL"<<endl;
			}
		}
	}
	return 0;
}
2024/7/15 19:57
加载中...