【每日一题 | 2025】3.3 ~ 3.9

在这里插入图片描述

个人主页:Guiat
归属专栏:每日一题

在这里插入图片描述

正文

1. 【3.3】10387 [蓝桥杯 2024 省 A] 训练士兵

题目链接:https://www.luogu.com.cn/problem/P10387

【AC_Code】

#include <iostream>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;

const int N = 1e6 + 10;
ll n, S, p[N], c[N], cnt[N], now, sum, Sum;

void solve()
{
	cin >> n >> S;
	for (int i = 1; i <= n; i ++)
	{
		cin >> p[i] >> c[i]; cnt[c[i]] += p[i]; now += p[i]; sum += p[i] * c[i];
	}
	for (int i = 1; i <= N; i ++)
	{
		if (now < S) break;
		Sum += S; sum -= now; now -= cnt[i];
	}
	cout << Sum + sum << '\n';
}

int main()
{
	IOS; solve();
	
	return 0;
}

2. 【3.4】P8601 [蓝桥杯 2013 省 A] 剪格子

题目链接:https://www.luogu.com.cn/problem/P8601

【AC_Code】

#include <iostream>
#include <algorithm>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int m, n, ff, a[15][15], dis[15][15], sum = 1, num = 0, b, c,
dx[5] = { 0, 1, -1, 0, 0 }, dy[5] = { 0, 0, 0, -1, 1 };

void DFS(int x, int y)
{
    if (2 * num > b) return ;
    if (b - num == num) { cout << sum; ff = 1; return ; }
    for (int i = 1; i <= 4; i ++)
    {
        int ux = x + dx[i], uy = y + dy[i];
        if (dis[ux][uy] == 0 && ux >= 1 && ux <= n && uy >= 1 && uy <= m)
        {
            dis[ux][uy] = 1; num += a[ux][uy]; sum ++;
            DFS(ux, uy);
            dis[ux][uy] = 0; num -= a[ux][uy]; sum --;
            if (ff) return ;
        }
    }	
    return ;
}

void solve()
{
    cin >> m >> n;
    for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++)
    {
        cin >> a[i][j]; b += a[i][j]; c = max(c, a[i][j]);
    }
    if (2 * c == b)
    {
        if (a[1][1] == c) cout << 1 << '\n';
        else cout << n * m - 1 << '\n';
        return ;
    }
    dis[1][1] = 1; num = a[1][1]; DFS(1, 1);
    if (!ff) cout << 0 << '\n';
}

int main()
{
    IOS; solve();
    
    return 0;
}

3. 【3.5】P9241 [蓝桥杯 2023 省 B] 飞机降落

题目链接:https://www.luogu.com.cn/problem/P9241

【AC_Code】

#include <iostream>
#include <algorithm>
#include <cstring>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int t, N, T[15], D[15], L[15], a[15];

bool DFS(int deep, int time)
{
	if (deep > N) return true;
	for (int i = 1; i <= N; i ++)
	{
		if (a[i] || T[i] + D[i] < time) continue;
		a[i] = 1;
		if (DFS(deep + 1, max(time, T[i]) + L[i])) { a[i] = 0; return 1; }
		a[i] = false;
	}
	return false;
}

void solve()
{
	cin >> t;
	while (t --)
	{
		cin >> N; for (int i = 1; i <= N; i ++) cin >> T[i] >> D[i] >> L[i];
		memset(a, 0, sizeof a);
		if (DFS(1, 0)) cout << "YES\n";
		else cout << "NO\n";
	}
}

int main()
{
	IOS; int _ = 1; while(_ --) solve();
	
	return 0;
}

4. 【3.6】P10578 [蓝桥杯 2024 国 A] 旋转九宫格

题目链接:https://www.luogu.com.cn/problem/P10578

【AC_Code】

#include <iostream>
#include <queue>
#include <map>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int T; string s, tar = "123456789"; char c;
map<string, int> mp; queue<string> q;

void BFS()
{
	q.push(tar); mp[tar] = 1;
	while (q.size())
	{
		string u = q.front(); q.pop(); string v[4] = { u, u, u, u };
		v[0][0] = u[1], v[0][1] = u[4], v[0][3] = u[0], v[0][4] = u[3];
		v[1][1] = u[2], v[1][2] = u[5], v[1][4] = u[1], v[1][5] = u[4];
		v[2][3] = u[4], v[2][4] = u[7], v[2][6] = u[3], v[2][7] = u[6];
		v[3][4] = u[5], v[3][5] = u[8], v[3][7] = u[4], v[3][8] = u[7];
		for (int i = 0; i < 4; i ++)
		{
			if (!mp[v[i]])
			{
				mp[v[i]] = mp[u] + 1;
				if (v[i] == tar) break;
				q.push(v[i]);
			}
		}
	}
}

void solve()
{
	cin >> T; BFS();
	while (T --)
	{
		s.clear();
		for (int i = 0; i < 9; i ++) cin >> c, s += c;
		cout << mp[s] - 1 << '\n';
	}
	
}

int main()
{
	IOS; solve();
	
	return 0;
}

5. 【3.7】P8642 [蓝桥杯 2016 国 AC] 路径之谜

题目链接:https://www.luogu.com.cn/problem/P8642

【AC_Code】

#include <iostream>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 25; bool vis[N][N];
int n, a[N], b[N], dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 }, len, ans[410];

inline void DFS(int x, int y)
{
	if (x < 1 || x > n || y < 1 || y > n || vis[x][y]) return ;
	for (int i = 1; i <= n; i ++) if (a[i] < 0 || b[i] < 0) return ;
	vis[x][y] = true; a[y] --; b[x] --; ans[++ len] = (x - 1) * n + y - 1;
	if (x == n && y == n)
	{
		for (int i = 1; i <= n; i ++)
		{
			if (a[i] != 0 || b[i] != 0) break;
			if (i == n) for (int i = 1; i <= len; i ++) cout << ans[i] << ' ';
		}
	}
	else for (int i = 0; i < 4; i ++) DFS(x + dx[i], y + dy[i]);
	a[y] ++; b[x] ++; vis[x][y] = false; len --;
}

inline void solve()
{
	cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; for (int i = 1; i <= n; i ++) cin >> b[i];
	DFS(1, 1);
}

int main()
{
	IOS; solve(); cout << '\n';
	
	return 0;
}

6. 【3.8】P8694 [蓝桥杯 2019 国 AC] 估计人数

题目链接:https://www.luogu.com.cn/problem/P8694

【AC_Code】

#include <iostream>
#include <vector>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 500; vector<int> g[N]; char c;
int n, m, sum, len, vis[N], f[N][N], M[N];
struct node { int x, y; } p[N];

void add(int a, int b) { g[a].push_back(b); g[b].push_back(a); }

bool go(int a)
{
	for (auto n : g[a])
	{
		if (vis[n]) continue;
		vis[n] = 1;
		if ( !M[n] || go(M[n]) ) { M[n] = a; return true; }
	}
	return false;
}

void solve()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++)
	{
		cin >> c; if (c == '1') p[++ len] = { i, j };
	}
	for (int i = 1; i <= len; i ++) for (int j = i + 1; j <= len; j ++)
	{
		if
		(
			p[i].x == p[j].x && p[i].y + 1 == p[j].y
			||
			p[i].x + 1 == p[j].x && p[i].y == p[j].y
		) f[i][j] = 1;
	}
	for (int k = 1; k <= len; k ++) for (int i = 1; i <= len; i ++) for (int j = 1; j <= len; j ++)
	{
		f[i][j] |= (f[i][k] & f[k][j]);
	}
	for (int i = 1; i <= len; i ++) for (int j = i + 1; j <= len; j ++) if (f[i][j]) add(i, j + len);
	for (int i = 1; i <= len; i ++)
	{
		fill(vis, vis + 1 + len * 2, 0); if (go(i)) sum ++;
	}
	cout << len - sum << '\n';
}

int main()
{
	IOS; solve();
	
	return 0;
}

7. 【3.9】数字接龙

题目链接:https://www.lanqiao.cn/problems/19712/learning/?page=1&first_category_id=1&name=%E6%95%B0%E5%AD%97%E6%8E%A5%E9%BE%99

【AC_Code】

#include <iostream>
#define IOS ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 15;
int n, k, nums[N][N],
dx[8] = { -1, -1, 0, 1, 1, 1, 0, -1 },
dy[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
string nber; bool vis[N][N], check[N][N][N][N];

bool dfs(int a, int b)
{
	if (a == n - 1 && b == n - 1) return nber.size() == n * n - 1;
	vis[a][b] = true;
	for (int i = 0; i < 8; i ++)
	{
		int x = a + dx[i], y = b + dy[i];
		if (x < 0 || x >= n || y < 0 || y >= n) continue;
		if (vis[x][y]) continue;
		if (nums[x][y] != (nums[a][b] + 1) % k) continue;
		if (i % 2 && (check[a][y][x][b] || check[x][b][a][y])) continue;
		check[a][b][x][y] = true; nber += i + '0';
		if (dfs(x, y)) return true;
		nber.pop_back(); check[a][b][x][y] = false;
	}
	vis[a][b] = false;
	return false;
}

void solve()
{
	cin >> n >> k;
	for (int i = 0; i < n; i ++) for (int j = 0; j < n; j ++) cin >> nums[i][j];
	if (!dfs(0, 0)) cout << -1 << '\n';
	else cout << nber << '\n';
}

int main()
{
	IOS; solve();
	
	return 0;
}

结语
感谢您的阅读!期待您的一键三连!欢迎指正!

在这里插入图片描述

内容概要:本文围绕SecureCRT自动化脚本开发在毕业设计中的应用,系统介绍了如何利用SecureCRT的脚本功能(支持Python、VBScript等)提升计算机、网络工程等相关专业毕业设计的效率与质量。文章从关键概念入手,阐明了SecureCRT脚本的核心对象(如crt、Screen、Session)及其在解决多设备调试、重复操作、跨场景验证等毕业设计常见痛点中的价值。通过三个典型应用场景——网络设备配置一致性验证、嵌入式系统稳定性测试、云平台CLI兼容性测试,展示了脚本的实际赋能效果,并以Python实现的交换机端口安全配置验证脚本为例,深入解析了会话管理、屏幕同步、输出解析、异常处理和结果导出等关键技术细节。最后展望了低代码化、AI辅助调试和云边协同等未来发展趋势。; 适合人群:计算机、网络工程、物联网、云计算等相关专业,具备一定编程基础(尤其是Python)的本科或研究生毕业生,以及需要进行设备自动化操作的科研人员; 使用场景及目标:①实现批量网络设备配置的自动验证与报告生成;②长时间自动化采集嵌入式系统串口数据;③批量执行云平台CLI命令并分析兼容性差异;目标是提升毕业设计的操作效率、增强实验可复现性与数据严谨性; 阅读建议:建议读者结合自身毕业设计课题,参考文中代码案例进行本地实践,重点关注异常处理机制与正则表达式的适配,并注意敏感信息(如密码)的加密管理,同时可探索将脚本与外部工具(如Excel、数据库)集成以增强结果分析能力。
在SR-TE(Segment Routing Traffic Engineering)策略配置中,端点(endpoint)和颜色(color)是两个关键属性,它们用于标识特定的路径约束和策略应用。端点通常是指SR-TE策略的目标节点,而颜色则用于将特定的流量标记为某种策略类别。 在Cisco设备上,配置SR-TE策略时使用`endpoint`和`color`命令是常见的做法。以下是一个典型的SR-TE策略配置示例,其中端点为`3.3.3.9`,颜色为`100`: ```bash segment-routing traffic-eng policy POLICY-NAME endpoint 3.3.3.9 color 100 ! candidate-paths preference 1 explicit segment-list SL1 ! ! ! ! ``` 在上述配置中: - `endpoint 3.3.3.9`定义了该SR-TE策略的目标节点,通常是远端的PE设备或特定的目的地[^1]。 - `color 100`用于将该策略与特定的流量分类关联,颜色值可以被BGP或其他路由协议用来匹配特定的流量策略[^1]。 颜色值通常用于在转发过程中提供额外的策略控制,例如在BGP中可以通过`color`属性来匹配特定的路由策略。端点和颜色的组合确保了流量可以按照预定义的路径进行转发,同时满足特定的服务质量要求。 ### 显式路径配置 在SR-TE策略中,除了定义端点和颜色外,还需要指定具体的路径。通常使用`segment-list`来定义显式的路径段。例如: ```bash segment-routing segment-list SL1 index 10 mpls label 1001 index 20 mpls label 2002 index 30 mpls label 3003 ! ! ``` 上述配置定义了一个名为`SL1`的段列表,其中包含三个MPLS标签,分别对应路径上的每个中间节点。这种方式允许网络管理员精确控制流量经过的路径。 ### 验证SR-TE策略 配置完成后,可以通过以下命令验证SR-TE策略的状态: ```bash show segment-routing traffic-eng policy ``` 该命令将显示所有已配置的SR-TE策略,包括端点、颜色、状态以及使用的段列表等信息。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

【Air】

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值