跳到正文

个人记录

8.13总结

yudazhou约 5 分钟
原文
文章信息与版本

文章信息

发布
2026年8月13日
收录
2026年8月14日
更新
2026年11月18日
篇幅
约 5 分钟

版本

  1. v1当前

一、比赛基本情况

比赛日期: 8.13

比赛时长: 120

比赛得分: 225

比赛排名:1

二、比赛整体回顾

做题顺序:1-2-3-4

时间安排:

T1:30min

T2:60min

T3:20min

T4:10min

比赛状态:感觉比较简单

整体感受:感觉比较简单

三、题目复盘

P5663 [CSP-J 2019] 加工零件

本题得分:20

考场思路:

正解想不出来,所以只拿了测试点 1∼4的分。

如果1和x有直接的连边,输出No,否则输出Yes。

考场代码:

C++
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N=2000020;
vector<int>g[N];
signed main()
{
	//freopen("pro.in","r",stdin);
	//freopen("pro.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m,q;
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	while(q--)
	{
		int x,y;
		cin>>x>>y;
		bool f=0;
		for(auto v:g[x])
		{
			if(v==1)
			{
				cout<<"Yes"<<endl;
				f=1;
				break;
			}
		}
		if(f==0)cout<<"No"<<endl;
	}
	return 0;
}

正确思路:

如果y是奇数,存在>=y的奇数路径就输出Yes.

如果y是偶数,存在>=y的偶数路径就输出Yes.

ji[x]:从起点走到x的最短奇数距离。

ou[x]:从起点走到x的最短偶数距离。

正确代码:

C++
#include<bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define endl '\n'
using namespace std;
const int N=2000020;
int ji[N],ou[N],vis[N];
vector<int>g[N];
void dj(int st)
{
	queue<int>q;
	memset(ji,0x3f,sizeof ji);
	memset(ou,0x3f,sizeof ou);
	memset(vis,0,sizeof vis);
	q.push(st); 
	ou[st]=0;
	while(q.size()>0)
	{
		int tmp=q.front();
		q.pop();
		for(int i=0;i<g[tmp].size();i++)
		{
			int v=g[tmp][i];
			if(ji[v]>ou[tmp]+1)
			{
				ji[v]=ou[tmp]+1;
				q.push(v);
			}
			if(ou[v]>ji[tmp]+1)
			{
				ou[v]=ji[tmp]+1;
				q.push(v);
			}
		}
	}
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m,q;
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dj(1);
	while(q--)
	{
		int x,y;
		cin>>x>>y;
		if(y%2==1&&ji[x]<=y)
		{
			cout<<"Yes"<<endl;
		}
		else if(y%2==0&&ou[x]<=y)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

P12284 [蓝桥杯 2024 国 Python A] 数字与留言

本题得分:5

初始思路:

由于想不到这题数位dp怎么写,所以骗了个分。

考场代码:

C++
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N=2000020;
signed main()
{
	//freopen("number.in","r",stdin);
	//freopen("number.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout<<1;
	return 0;
}

正确思路:

用数位dp求出1 ~ x里面余数为0 ~ 2023 的有多少个。

正确代码:

原文