跳到正文

个人记录

CSP2021 J自测有感

2021hych约 6 分钟
原文
文章信息与版本

文章信息

发布
2021年10月29日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 6 分钟

版本

  1. v2当前
  2. v1

title1title1:T1⟶T1\longrightarrow我真的对了吗?

T1T1确实是个数学水题,但……\dots\dots 我真的是对的吗 ((疑惑ing))。 根据良心人士的正解,我发现,我好蒻啊 别人的代码:

C++
#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;
}

真好,orzorz。 我的代码:

C++
#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;
}

都是O(1)O(1)我咋写的那么长? 后来才发现我喜欢把事情搞复杂了。反正A了不知道CCFCCF的数据我能AA吗?

title2title2:T2⟶T2\longrightarrow两个晚上才AA!!!

T2T2是一道思维题我保证比T1T1难。 有趣的是我打了好几个代码,心态炸裂。

∙\bullet代码11

一开始直接吓死,以为是SpalySpaly,打了半天,结果样例都过不了。

∙\bullet代码22

脑子抽筋,想利用洛谷的民间弱弱数据AA掉,打了个暴力,结果8080。

∙\bullet代码33

再挑战平衡树,不过用pbdspbds,结果和第一次一样,样例都不过。

∙\bullet代码44

原本是想放弃不过,仔细想了想,想到了11操作O(n)O(n),22操作O(1)O(1)的绝妙方法算法。然后就开心的AA了!!

四次代码终于让我体会到了OIOI的险恶。

title3title3:T3⟶T3\longrightarrow配吗?

第三题题目老长了,感觉好难的样子,但……\dots\dots 中等模拟题!!!这作为T3T3有点不够资格诶。 只不过,不知道CCFCCF的数据我能AA吗?反正洛谷上AA了。 我的蒻蒻代码:

C++
#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;
}

错了就尴尬了。呵呵!!

title4title4:T4⟶T4\longrightarrow真oror假·模拟题?

T4T4是一个非常令我苦恼的题,我搞了好久,QAQQAQ。 和T2T2一样写了好几次代码。

∙\bullet代码11

第一眼,额,水,队列直接上。然后就7070了。

∙\bullet代码22

想了一想,好像是并查集诶,抓紧干,结果……\dots\dots 样例都没过,可恶的OIOI。

∙\bullet代码3,4,53,4,5

由于心态问题,开始了很多变态思路,我又想打SplaySplay了,打了个正常的,样例没过。pbdspbds版的,还是没过。后来出现了各种各样的数据结构,全错。

∙\bullet代码66

已经没有心态了,觉得已经挺好了,但睡觉的时候灵机一动,双向链表好像也可以。第二天起来准备trytry oneone trytry。结果……\dots\dots AA了,OIOI真有趣。

title5title5:总结⟶\longrightarrow真的水?

相信谁都认为这次简单,但……\dots\dots 现场考呢?OIOI的难熬和第一次比赛的紧张感,无不压迫着每一位OIEROIER。 实话来讲,这次的难度不是太难,但还是有一定的思维系数。那最后评一个等级吧!!

满分: ⋆\star ⋆\star ⋆\star ⋆\star ⋆\star

算法难度:⋆\star ⋆\star

坑人级别:⋆\star

语文水平:⋆\star ⋆\star ⋆\star ⋆\star ⋆\star

思维含金量:⋆\star ⋆\star ⋆\star

个人总评:⋆\star ⋆\star ⋆\star ⋆\star

终于写完了。

THETHE ENDEND

原文