错了 #13 #14 #17到 #21
#include<bits/stdc++.h>
using namespace std;
struct node{
int num;
int ad[10];
}a[10010],b[10010];
int n,lena,lenb,st[10010];
bool check(node x,node y){
for(int i = 0;i<5;i++)
if(x.ad[i]!=y.ad[i])
return false;
return true;
}
int main(){
scanf("%d",&n);
for(int i = 1;i<=n;i++){
string s1,s2;
cin>>s1>>s2;
int x = -1,step = 0;node y;
for(int j = 0;j<s2.size();j++){
if(s2[j]>='0'&&s2[j]<='9'){
if(j+1<s2.size())
if(s2[j+1]<='9'&&s2[j+1]>='0'&&s2[j]=='0'&&(s2[j-1]>'9'||s2[j-1]<'0'))
st[i] = 3;
if(x==-1) x = 0;
x = x*10+(s2[j]-48);
}else{
if(x>255) st[i] = 3;
if(x==-1) st[i] = 3;
y.ad[step++] = x;
if(step==4){
if(s2[j]!=':') st[i] = 3;
}else{
if(s2[j]!='.') st[i] = 3;
}
if(step>4) st[i] = 3;
x = 0;
}
}
y.ad[4] = x;
if(x>65535) st[i] = 3;
if(st[i]!=0) continue;
if(s1=="Server"){
lena++;
a[lena] = y;
a[lena].num = i;
}else{
lenb++;
b[lenb] = y;
b[lenb].num = i;
}
}
for(int i = 1;i<lena;i++)
for(int j = i+1;j<=lena;j++)
if(check(a[i],a[j])){
st[a[j].num] = 2;
a[j].num = a[i].num;
}
for(int i = 1;i<=lena;i++) st[a[i].num] = 1;
for(int i = 1;i<=lena;i++)
for(int j = 1;j<=lenb;j++)
if(check(a[i],b[j])&&a[i].num<b[j].num)
st[b[j].num] = 3+a[i].num;
for(int i = 1;i<=n;i++){
if(st[i]==0) puts("FAIL");
else if(st[i]==1) puts("OK");
else if(st[i]==2) puts("FAIL");
else if(st[i]==3) puts("ERR");
else printf("%d\n",st[i]-3);
}
return 0;
}