数据过水,要加hack
2026-10-20 09:18:03
发布于:广东
3阅读
0回复
0点赞
本人觉得数据过水了,其实@.云志.(〃'▽'〃)的代码有误
可以放long long卡人,只有65pts(在oiclass上我被坑了10多min)
本题就是用字符串来模拟,别用scanf!
代码
#include<bits/stdc++.h>
using namespace std;
const int N=1050;
int t;map<string,int>mp;
bool dck(char ch,int cnt,int zzy){
if(zzy==0)return 1;
if(cnt<3&&ch!='.')return 1;
if(cnt==3&&ch!=':')return 1;
if(cnt>=4)return 1;
return 0;
}
bool www(char ch){return ch=='.'||ch==':';}
bool ck(string s){
int l=s.size();
s=" "+s;
long long cnt=0,sz=0,zzy=0;
for(int i=1;i<=l;i++){
if(www(s[i])){
if(dck(s[i],cnt,zzy))return 1;
if(cnt<3&&sz>255)return 1;
if(cnt==3&&sz>255)return 1;
cnt++;sz=0;zzy=0;
}else{
if(s[i]<'0'||s[i]>'9')return 1;
if(zzy==0&&s[i]=='0'&&i<l&&s[i+1]>='0'&&s[i+1]<='9')return 1;
sz=sz*10+s[i]-'0';zzy++;
}
if(sz>=1000000)return 1;
}
if(cnt!=4||zzy==0)return 1;
if(sz>65535)return 1;
return 0;
}
int main(){
cin>>t;
for(int i=1;i<=t;i++){
string s,bh;
cin>>s>>bh;
if(ck(bh)==1){cout<<"ERR\n";continue;}
else if(s=="Server"){
if(!mp[bh]){cout<<"OK\n";mp[bh]=i;}
else cout<<"FAIL\n";
}
else if(!mp[bh])cout<<"FAIL\n";
else cout<<mp[bh]<<"\n";
}
return 0;
}
这里空空如也







有帮助,赞一个