CSP2021 J自测有感
title1 :T1\longrightarrow 我真的对了吗?
我真的是对的吗
根据良心人士的正解,我发现,我好蒻啊
别人的代码:
#include<bits/stdc++.h>
using namespace std;
int n,l,r;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>l>>r;
if(r/n==l/n) cout<<r%n;
else cout<<n-1<<endl;
return 0;
}
真好,
我的代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,l,r,J,maxR;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>l>>r;
J=(l-1)/n*n+n;
if(J<=r) {
if(r-J>=n-1) {
cout<<n-1;
return 0;
}
else maxR=r-J;
if(J-l>=1) {
cout<<n-1;
return 0;
}
else {
cout<<maxR;
return 0;
}
}
else cout<<r%n;
return 0;
}
都是
后来才发现我喜欢把事情搞复杂了。反正A了不知道
title2 :T2\longrightarrow 两个晚上才A !!!
一开始直接吓死,以为是
\bullet 代码2
脑子抽筋,想利用洛谷的民间弱弱数据
\bullet 代码3
再挑战平衡树,不过用
\bullet 代码4
原本是想放弃不过,仔细想了想,想到了绝妙方法算法。然后就开心的
四次代码终于让我体会到了
title3 :T3\longrightarrow 配吗?
第三题题目老长了,感觉好难的样子,但
中等模拟题!!!这作为
只不过,不知道反正洛谷上
我的蒻蒻代码:
#include<bits/stdc++.h>
#define r register
using namespace std;
int n;
string s,IP;
map<string ,int>Map;
bool check(string str) {
int f1=0,f2=0;
for(int i=0;i<str.size();i++) {
if(str[i]=='.') f1++;
else if(str[i]==':'&&f1!=3) return false;
else if(str[i]==':') f2++;
}
if(f1!=3||f2!=1) return false;
int cnt=0,f3=0,x=0;
for(int i=0;i<str.size();i++)
if(isdigit(str[i])) {
if(f3!=1) {
f3=1;
cnt++;
if(isdigit(str[i+1])&&str[i]=='0') return false;
}
x=x*10+str[i]-'0';
}
else {
f3=0;
if(x>255) return false;
x=0;
}
if(cnt!=5) return false;
if(x>65535) return false;
return true;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(r int i=1;i<=n;i++) {
cin>>s>>IP;
if(s=="Server")
if(!check(IP)) cout<<"ERR"<<endl;
else
if(!Map[IP]) {
Map[IP]=i;
cout<<"OK"<<endl;
}
else cout<<"FAIL"<<endl;
else
if(!check(IP)) cout<<"ERR"<<endl;
else
if(Map[IP]) cout<<Map[IP]<<endl;
else cout<<"FAIL"<<endl;
}
return 0;
}
错了就尴尬了。呵呵!!
title4 :T4\longrightarrow 真or 假·模拟题?
第一眼,额,水,队列直接上。然后就
\bullet 代码2
想了一想,好像是并查集诶,抓紧干,结果
样例都没过,可恶的
\bullet 代码3,4,5
由于心态问题,开始了很多变态思路,我又想打
\bullet 代码6
已经没有心态了,觉得已经挺好了,但睡觉的时候灵机一动,双向链表好像也可以。第二天起来准备
现场考呢?
实话来讲,这次的难度不是太难,但还是有一定的思维系数。那最后评一个等级吧!!
满分: \star \star \star \star \star
算法难度:\star \star
坑人级别:\star
语文水平:\star \star \star \star \star
思维含金量:\star \star \star
个人总评:\star \star \star \star
终于写完了。