【每日一题 | 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;
}

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

在这里插入图片描述

在人工智能研究的前沿,自然语言理解技术正受到广泛关注,其涵盖语音转写、跨语言转换、情绪判别及语义推断等多个分支。作为该领域的基石方法之一,基于大规模文本预先训练的语言表征模型,能够从海量语料中学习深层的语言规律,从而为各类后续应用任务提供强有力的语义表示支持。得益于硬件算力的提升与模型架构的持续优化,这类预训练模型已在多项自然语言理解评测中展现出卓越的性能。 本文重点探讨中文环境下的三项典型自然语言处理任务:TNEWS新闻主题归类、OCEMOTION情感倾向判断以及OCNLI语义推理验证。这三项任务分别对应文本分类、情感分析与逻辑推理三大核心方向,共同构成了从基础文本理解到复杂语义推演的技术链条。 TNEWS新闻主题归类任务旨在对涵盖政治、经济、科技、体育等多领域的新闻文本进行自动类别划分。该任务要求模型准确识别文本主旨并完成分类,属于典型的文本分类问题。 OCEMOTION情感分析任务则专注于从社交媒体、论坛评论等短文本中识别用户的情感极性。情感分析作为文本理解的重要维度,可为商业决策、舆情监测等提供关键依据,具有显著的应用价值。 OCNLI语义推理任务需要模型依据给定的前提语句与假设语句,判断后者是否可由前者逻辑推导得出。该任务检验模型对语句间语义关联与推理关系的理解能力,是衡量自然语言理解深度的重要标杆。 在上述任务中,数据分布的多标签与类别不均衡现象构成主要挑战。多标签指单一文本可能归属多个类别,而不均衡则表现为各类别样本数量差异悬殊。这种不平衡分布易导致模型过度拟合多数类别,从而削弱其泛化性能。为应对该问题,本方案综合采用了数据重采样、损失函数加权调整等技术,以提升模型在少数类别上的识别效果。 深度学习方法是实现上述任务的核心技术路径。通过设计多层神经网络结构,模型能够自动提取文本的深层特征,并建立从原始输入到任务目标的端到端映射。本方案所涉及的技术体系包括卷积神经网络、循环神经网络、长短期记忆网络以及基于自注意力机制的Transformer架构等。 参赛者需对提供的数据集进行预处理与分析,构建高效的深度学习模型,并通过训练、验证与测试环节系统评估模型性能。借助天池平台提供的强大算力资源与预训练模型基础,参赛者可进一步优化模型设计,提升任务表现。 本次研究不仅着眼于在特定评测任务上取得优异成绩,更致力于深入探索中文自然语言处理中的实际难题,为未来智能化应用与学术研究积累方法经验与技术储备。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
在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、付费专栏及课程。

余额充值