跳到正文

个人记录

东塘周二晚上训练课【401】总结

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

文章信息

发布
2025年5月8日
收录
2025年12月12日
更新
2026年11月8日
篇幅
约 6 分钟

版本

  1. v1当前

东塘周二晚上训练课【401】总结

作者又双叒叕来写总结了TwT

240分……

按顺序来

T1

40分 思路……好像没有思路。

模拟,模拟,还是模拟

代码其实对了,但是40分,就是因为 m,n输入反了{\color{red} m,n输入反了}
csp不能这样了。
反正正确代码与错误代码没有多少区别错误代码就不贴了

正确代码

C++
#include<bits/stdc++.h> 
using namespace std;
int x[1005][1005],y[1005][1005];
int main()
{
	int n,m,sx,sy;
	cin>>m>>n>>sx>>sy;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>x[i][j]>>y[i][j];
		}
	}
	cout<<sx<<' '<<sy<<endl;
	while(x[sx][sy]!=0&&y[sx][sy]!=0)
	{
		cout<<x[sx][sy]<<' '<<y[sx][sy]<<endl;
		int xx=x[sx][sy],yy=y[sx][sy];
		sx=xx;
		sy=yy;
	}
	return 0;
}

原题目:B3702 [语言月赛202301] 华小科的旅行开始了

T2

100分 思路是我写暴力解时想到的。
首先明确一点,十位的数是不会影响个位的
个位最大为9,那么9×3>239\times3>23
暴力枚举三个个位相加之和%10=3{三个个位相加之和\% 10 = 3}的所有可能

额……打表 然后,本题完结 是的,作者用的if

C++
#include<bits/stdc++.h> 
using namespace std;
int t[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		t[a%10]++;
	}//手废了
	if((t[0]>=2&&t[3]>=1)||(t[0]>=1&&t[1]>=1&&t[2]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[0]>=1&&t[4]>=1&&t[9]>=1)||(t[0]>=1&&t[5]>=1&&t[8]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if(t[1]>=3||(t[0]>=1&&t[6]>=1&&t[7]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[1]>=1&&t[3]>=1&&t[9]>=1)||(t[1]>=1&&t[4]>=1&&t[8]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[1]>=1&&t[5]>=1&&t[7]>=1)||(t[1]>=1&&t[6]>=2))
	{
		cout<<"YES";
		return 0;
	}
	if((t[2]>=2&&t[9]>=1)||(t[2]>=1&&t[3]>=1&&t[8]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[2]>=1&&t[4]>=1&&t[7]>=1)||(t[2]>=1&&t[5]>=1&&t[6]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[3]>=2&&t[7]>=1)||(t[3]>=1&&t[4]>=1&&t[6]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[3]>=1&&t[5]>=2)||(t[4]>=2&&t[5]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[5]>=1&&t[9]>=2)||(t[6]>=1&&t[8]>=1&&t[9]>=1))
	{
		cout<<"YES";
		return 0;
	}
	if((t[7]>=2&&t[9]>=1)||(t[7]>=1&&t[8]>=2))
	{
		cout<<"YES";
		return 0;
	}
	cout<<"NO";
	return 0;
}

T3

100分
思路: 栈栈栈\normalsize栈 \large栈 \Large栈

直接用栈模拟,但是千万不要算次方,合并aia_i与ai+1a_i+1的结果直接使用ai+1a_i +1即可。

C++
#include<bits/stdc++.h> 
using namespace std;
int a[1000000];
stack<int>s;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	s.push(a[1]);
	for(int i=2;i<=n;i++)
	{
		s.push(a[i]);
		while(1) 
		{
			if(s.size()<2)
			{
				break; 
			}
			int x=s.top();
			s.pop();
			int y=s.top();
			s.pop();
			if(x!=y)
			{
				s.push(y);
				s.push(x);
				break;
			}
			else
			{
				s.push(x+1);
			}
		}
	}
	cout<<s.size();
	return 0;
}

T4

0分
分析题目: i+j+k=li+j+k=l

三种解:o(n4),o(n3),o(n2){\color{orange}o(n^4),}{\color{gold}o(n^3),}{\color{lightgreen}o(n^2)}

o(n4):{\color{orange}o(n^4)}:

枚举i,j,k,li,j,k,l

o(n3):{\color{gold}o(n^3)}:

枚举i、j、ki、j、k,用桶确定i+j+ki+j+k是否存在

o(n2):{\color{lightgreen}o(n^2)}:

i+j+k=li+j+k=l->i+j=l−ki+j=l-k

  • n2:n^2:用桶确定l−kl-k存在
  • n2:n^2:枚举i、ji、j用桶确定i+ji+j是否存在
C++
#include<bits/stdc++.h> 
using namespace std;
map<int,int>mp;
int a[10005],n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			mp[a[i]+a[j]]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(mp[a[i]-a[j]])
			{
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}
原文