社区讨论
65pts求条
P7911[CSP-J 2021] 网络连接参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mhj377c5
- 此快照首次捕获于
- 2025/11/03 19:59 4 个月前
- 此快照最后确认于
- 2025/11/03 19:59 4 个月前
CPP
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
string ip[1005];
int main(){
//freopen("code.in","r",stdin);
//freopen("code.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(ll i=1;i<=n;i++){
string op,ad;
cin>>op>>ad;
ll a,b,c,d,e;
if(sscanf(ad.c_str(),"%d.%d.%d.%d:%d",&a,&b,&c,&d,&e)!=5){
cout<<"ERR"<<endl;
continue;
}
if(!(a<=255&&b<=255&&c<=255&&d<=255&&e<=65535)){
cout<<"ERR"<<endl;
continue;
}
if(op=="Server"){
bool flag=true;
for(ll j=1;j<=i;j++){
if(ip[j]==ad){
cout<<"FAIL"<<endl;
flag=false;
break;
}
}
if(flag){
cout<<"OK"<<endl;
ip[i]=ad;
}
}else{
bool flag=false;
for(ll j=1;j<=i;j++){
if(ip[j]==ad){
cout<<j<<endl;
flag=true;
break;
}
}
if(flag==false){
cout<<"FAIL"<<endl;
}
}
}
//fclose(stdin);
//fclose(stdout);
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...