Subtask #0中第#13我将答案一个一个对照。
但是还有第989个字符串过不了。 应该输出ERR,我输出FAIL。
这个是问的:
Client 179.130.189.162:2813075
求大佬看看代码!这个怎么判?我没法了。
#include<bits/stdc++.h>
#define int long long
using namespace std;
//vector<string> vs;
map<string,int> m;
int cnt=1;
signed main(void){
int n;
cin>>n;
for(int i=1;i<=n;i++){
string s1,s2;
cin>>s1>>s2;
int l1=s2.length();
if(l1<9){
cout<<"ERR"<<endl;
continue;
}
int dd=0,k=0;
int fff=0;
string a="",b="",c="",d="",e="";
for(int j=0;j<l1;j++){
if(s2[j]=='.'){
dd++;
if(k!=0){
fff=1;
}
continue;
}
if(s2[j]==':'){
// e+=s2[j];
k++;
// dd++;
if(dd!=3){
fff=1;
}
continue;
}
if(k!=0){
e+=s2[j];
}
if(dd==0){
a+=s2[j];
}
if(dd==1){
b+=s2[j];
}
if(dd==2){
c+=s2[j];
}
if(dd==3 && k==0){
d+=s2[j];
}
}
if(fff==1){
cout<<"ERR"<<endl;
continue;
}
int aa=0,bb=0,cc=0,_d=0,ee=0,o,kkk;
int al=a.length(),bl=b.length(),cl=c.length(),dl=d.length(),el=e.length();
for(o=al-1,kkk=1;o>=0;o--,kkk*=10){
aa+=((int)a[o]-48)*kkk;
}
for(o=bl-1,kkk=1;o>=0;o--,kkk*=10){
bb+=((int)b[o]-48)*kkk;
}
for(o=cl-1,kkk=1;o>=0;o--,kkk*=10){
cc+=((int)c[o]-48)*kkk;
}
for(o=dl-1,kkk=1;o>=0;o--,kkk*=10){
_d+=((int)d[o]-48)*kkk;
}
for(o=el-1,kkk=1;o>=0;o--,kkk*=10){
ee+=((int)e[o]-48)*kkk;
}
if((a[0]=='0'&&aa!=0) || (b[0]=='0'&&bb!=0) || (c[0]=='0'&&cc!=0) || (d[0]=='0'&&_d!=0) || (e[0]=='0'&&ee!=0)){
cout<<"ERR"<<endl;
continue;
}
// cout<<aa<<" "<<bb<<" "<<cc<<" "<<_d<<" "<<ee<<endl;
if(aa<0 || aa>255 || bb<0 || bb>255 || cc<0 || cc>255 || _d<0 || _d>255){
cout<<"ERR"<<endl;
continue;
}
if(ee<0 || ee>65535){
cout<<"ERR"<<endl;
continue;
}
if(dd!=3 || k!=1){
cout<<"ERR"<<endl;
continue;
}
if(s1=="Server"){
if(m[s2]!=0){
cout<<"FAIL"<<endl;
} else {
// cout<<m[s2]<<endl;
m[s2]=i;
// cnt++;
cout<<"OK"<<endl;
}
}
if(s1=="Client"){
if(m[s2]==0){
cout<<"FAIL"<<endl;
} else {
cout<<m[s2]<<endl;
}
}
}
return 0;
}