记录
看 #8 提示第 5 行应输出 FAIL,实际输出 ERR,可我在洛谷 IDE 试,第 5 行 输出的就是 FAIL 啊?
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n , a , b , c , d , e , sum;
string op , ad;
bool flag;
map<string , int> server;
bool check()
{
char tad[30];
for (int i = 0 ; i < ad.length() ; i++) tad[i] = ad[i];
if (sscanf(tad , "%d.%d.%d.%d:%d" , &a , &b , &c , &d , &e) < 5) return false;
if (!(a >= 0 && a <= 255)) return false;
if (!(b >= 0 && b <= 255)) return false;
if (!(c >= 0 && c <= 255)) return false;
if (!(d >= 0 && d <= 255)) return false;
if (!(e >= 0 && e <= 65535)) return false;
char ntad[30];
sprintf(ntad , "%d.%d.%d.%d:%d" , a , b , c , d , e);
for (int i = 0 ; i < ad.length() ; i++)
if (ntad[i] != tad[i]) return false;
return true;
}
signed main()
{
//freopen("P7911_8.in" , "r" , stdin);
//freopen("P7911_8.out" , "w" , stdout);
cin >> n;
while (n--)
{
cin >> op >> ad;
++sum; flag = check();
if (!flag) {cout << "ERR\n"; continue;}
else
{
if (op == "Server")
{
if (server[ad] == 0)
{
cout << "OK\n"; server[ad] = sum;
continue;
}
else {cout << "FAIL\n"; continue;}
}
else
{
if (server[ad] > 0) {cout << server[ad] << "\n"; continue;}
else {cout << "FAIL\n"; continue;}
}
}
}
return 0;
}