cf Educational Codeforces Round 32

【AI】使用Cursor和AI编程生成的VUE前端框架 本项目是一个基于VUE.js的前端框架,结合了登录、图形验证码、权限校验等常用功能模块。通过与Cursor AI交互生成的代码,展示了AI在编程中的潜力与效率。 阅读详情

ABC题巨水,D题推导公式后可以快速解决。

没有打实时场,开了一场Virtual。AB题很轻松,然而手速比较慢。

C题其实也很水,可是一直写的很屎,开场11分钟就开了的题,甚至到离结束还有11分钟左右才过,可见码力若的不行。

C题wa太多了,期间get到D的公式,快速通过D题后回头看C,头脑似乎清醒了些,找到了C的错误,才得以AC,可是时间已经不够开后面的题了(虽说开了也不一定会做)。



A. Local Extrema

题意:给定一个长度为n的数组,忽略头尾,定义一个数若比两边都大则称为local maximum,比两边都小则称为local minimum,统称为local extrema。让你求出local extrema的数的总个数。

十分水,存储后处理即可

#include <cstdio>

int main (void){
	
	int n , a[1005] = {} , ans = 0 ;
	scanf ("%d", &n );
	for ( int i = 0 ; i < n ; i ++ ){
		scanf ("%d", &a[i] );
	}
	for ( int i = 1 ; i < n - 1 ; i ++ ){
		if ( ( a[i] > a[i-1] && a[i] > a[i+1] ) || ( a[i] < a[i-1] && a[i] < a[i+1] ) ){
			ans ++ ;
		}
	}
	printf ("%d\n", ans );
	return 0;
}

B. Buggy Robot

题意:有一个机器人,初始位于(0,0)位置,给你一串包含UDLR的字符串,表示它可能的行动,U、D、L、R分别表示向上走(up)、向下走(down)、向左走(left)、向右走(right)一格,要求行动结束后仍位于(0,0)位置,要你输出最大可能的行动次数。

思路:考虑到终点与起点要在同一个点,所以一个U一定对应一个D,一个L一定对应一个R。所以只需记录UDLR各自出现的次数,然后取UD中次数小的那个,加上LR中次数小的那个,即为总的行动对的个数,将行动对个数乘以二即为总的行动次数。


#include <cstdio>
#include <algorithm>

using namespace std;

int main (void){
	
	int n , num[4] = {} ;
	scanf ("%d",&n );
	char str[105] ;
	scanf ("%s", str );
	for ( int i = 0 ; i < n ; i ++ ){
		if ( str[i] == 'L' )	num[0] ++ ;
		if ( str[i] == 'R' )	num[1] ++ ;
		if ( str[i] == 'U' )	num[2] ++ ;
		if ( str[i] == 'D' )	num[3] ++ ;
	}
	
	int ans = ( min ( num[0] , num[1] ) + min ( num[2] , num[3] ) ) * 2 ;
	
	printf ("%d\n", ans );
	
	return 0;
}

C. K-Dominant Character

题意:给你一个字符串s,要求找到一个最小的k,使得对于s的每一个长度为k的子串,都有同一个字符c出现。如样例1:abacaba,输出结果为2:对于每个长度为2的子串,都有字符'a'出现。

思路:其实很简单,输入只包含小写字母,只需要记录每个字符的间隔最大值,然后再取出所有最大值中的最小值即可。维护最大值:在字符第一次出现的时候记录间隔最大值为第一次出现的下标+1,在遍历过一遍串s后,维护最大值为(当前最大值)与(字符最后一次出现到串s结束的长度)之间的最大值。


其实是一道很简单的题,但是头脑不清醒维护条件一直写wa,弱的不行了。


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void){
	
	char str[100005] ;
	int tag[26] , maxn[26] = {} , num[26] = {} ;
	memset ( tag , -1 , sizeof ( tag ) );
	scanf ("%s", str );
	int len = strlen ( str );
	
	for ( int i = 0 ; i < len ; i ++ ){
		if ( tag[str[i]-'a'] == -1 )	maxn[str[i]-'a'] = i + 1 ;
		if ( tag[str[i]-'a'] != -1 ){
			maxn[str[i]-'a'] = max ( i - tag[str[i]-'a'] , maxn[str[i]-'a']);
		}
		tag[str[i]-'a'] = i ;
		num[str[i]-'a'] ++ ;
	}
	
	for ( int i = 0 ; i < 26 ; i ++ ){
		if ( num[i] <= 1 ){
			maxn[i] = 1000000 ;
		}
	}
	
	for ( int i = 0 ; i < 26 ; i ++ ){
		maxn[i] = max ( maxn[i] , len - tag[i] );
	}
	
	int minn = 10000000 ;
	for ( int i = 0 ; i < 26 ; i ++ ){
		if ( tag[i] != -1 && maxn[i] != 0 ){
			minn = min ( minn , maxn[i] );
		}
	}
	
	minn = min ( minn , len / 2 + 1);
	
	printf ("%d\n", minn );
	
	return 0;
}

D. Almost Identity Permutations

题意:给定n和k,n表示一个序列的长度(序列中只包含值为1-n的元素),问你这n个数的排列中有多少个满足:至少有n-k个值满足Pi = i (即处在原来位置)。

以样例1为例:n = 4 , k = 2,问有几个排列满足至少有n-k=2个值处在原来位置,易知答案7的得来:

(1)1 2 3 4   (2)1 2 4 3   (3) 1 4 3 2   (4) 1 3 2 4   (5) 4 2 3 1   (6) 3 2 1 4   (7) 2 1 3 4

思路:k只有1-4四种选择,可以很容易的分析出:

当k=1时,结果为1;

当k=2时,先从n个数中取出n-2个数,表示这n-2个数是处在原位上的,然后a b这两个n-2之外的数交换位置,只有一种情况,所以k=2时,结果为C(n,n-2)*1+1;

当k=3时,同2理,取出n-3个数,剩下3个数(a,b,c)考虑3个数都不在各自位置上的情况,共有两种情况:(b,c,a) 和 (c,a,b),所以k=3时,结果为C(n,n-3)*2+C(n,n-2)*1+1;

当k=4时,同上,取出n-4个数,剩下4个数(a,b,c,d)都不在各自位置上的情况有9种:(b,a,d,c) , (b,c,d,a) , (b,d,a,c) , (c,a,d,b) , (c,d,a,b) , (c,d,b,a) , (d,a,b,c) , (d,c,a,b) , (d,c,b,a),共9种情况,所以k=4时,结果为C(n,n-4)*9+C(n*n-3)*2+C(n,n-2)*1+1。

至于为什么每次都要加上前一个k的结果,是因为要求的是至少有n-k个值满足,当k减小时n-k增大,显然也符合。

由于懒得写组合数,也懒得化简分式,导致第一发wa掉了,于是直接改用java跑大数。


import java.util.Scanner ;
import java.math.* ;

public class Main {
	public static void main ( String[] args ) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt() , k = in.nextInt() ;
		
		in.close();
		
		BigInteger n1 = BigInteger.valueOf(1) ;
		BigInteger n2 = BigInteger.valueOf(n).multiply(BigInteger.valueOf(n-1)).divide(BigInteger.valueOf(2));
		BigInteger n3 = BigInteger.valueOf(n).multiply(BigInteger.valueOf(n-1).multiply(BigInteger.valueOf(n-2))).divide(BigInteger.valueOf(6));
		BigInteger n4 = BigInteger.valueOf(n).multiply(BigInteger.valueOf(n-1).multiply(BigInteger.valueOf(n-2).multiply(BigInteger.valueOf(n-3)))).divide(BigInteger.valueOf(24));
		
		if ( k == 1 ) {
			System.out.println( n1 );
		} else if ( k == 2 ) {
			System.out.println( n1.add(n2) );
		} else if ( k == 3 ) {
			System.out.println( n1.add(n2).add(n3.multiply(BigInteger.valueOf(2))) );
		} else if ( k == 4 ) {
			System.out.println( n1.add(n2).add(n3.multiply(BigInteger.valueOf(2))).add(n4.multiply(BigInteger.valueOf(9))) );
		}
		
	}
}

有点补不动题,而且期中考试临近,该复习了,有空的话会补题的。

【OpenClaw企业级智能体实战】第11篇:制造业设备预测性维护实战——OpenClaw+DeepSeek+Prometheus从零搭建(附完整代码) 本文聚焦制造业设备预测性维护的核心痛点,基于OpenClaw v2026.2.1、DeepSeek智能诊断、Prometheus监控等工具,拆解“设备状态监控→智能故障诊断→预测性维护”三大核心场景。从技术原理、算法构建、实操流程到完整代码实现,提供“数据采集→模型训练→智能调度→自动处置”的全链路方案。方案遵循工业安全规范,采用“只读优先、权限最小化”原则,适配中小制造企业落地需求。通过虚拟案例验证,可使设备非计划停机时间下降65%、平均修复时间缩短47%,既适合新手快速入门,也为进阶读者提供架构优化思路 阅读详情

相关推荐

对计算机专业来说学历真的重要吗?

我本科学校是渣渣二本,研究生学校是985,现在毕业五年,校招笔试、面试,社招面试参加了两年了,就我个人的经历来说下这个问题。 这篇文章很长,但绝对是精华,相信我,读完以后,你会知道学历不好的解决方案,记得帮我点赞哦。 先说结论,无论赞不赞同,它本质就是这样:对于技术类工作而言,学历五年以内非常重要,但有办法弥补。五年以后,不重要。 目录: 张雪峰讲述的事实 我看到的事实 为什么会这样 ...

启舰 55万+

cf Educational Codeforces Round 177 C. Disappearing Permutation

C. Disappearing Permutation time limit per test2 seconds memory limit per test512 megabytes A permutation of integers from 1 to n is an array of size n where each integer from 1 to n appears exactly once.You are given a permutation p of integers from 1 to

@fei 1174

告别远程控制弹窗:免Root实现投射与录制敏感信息自动授权

本文针对Android远程控制中频繁出现的‘在投射和录制时显示敏感信息’弹窗问题,提供了一套免Root的自动化解决方案。通过结合Shizuku与App Ops两款工具,无需破解系统即可静默授予屏幕投射与录制权限,从而实现稳定、无干扰的远程协助、家庭监控或自动化测试,彻底告别手动授权弹窗的烦恼。

qsc9012345的博客 716

Educational Codeforces Round 60 (Rated for Div. 2)(题解)

Educational Codeforces Round 60 (Rated for Div. 2)(题解) A. Best Subsegment 题目大意 给出一段序列,找出这段序列的子序列,使得子序列的平均值尽可能大.如有平均值相等的情况,输出长度尽可能长的.问这种序列的长度 解题思路 即最大值最长连续有多长 AC代码 #include&lt;bits/stdc++.h&gt; using n...

FLY_WHITE的博客 847

Google AdSense收款前必做:W-8BEN税务认证的3个关键选择与1个提交时机小技巧

本文深入解析Google AdSense收款前必须完成的W-8BEN税务认证,重点介绍账号类型选择、特殊税率勾选、美国活动界定等3个关键决策,并分享提交时机的小技巧,帮助站长高效通过审核,确保广告收入顺利到账。

weixin_30443731的博客 671

Jetson Orin Nano 平台适配IMX585 camera驱动调试记录

Jetson Orin Nano Devkit适配imx585 camera使用argus_camera捕获流,图片是黑色的用示波器来测量mipi信号,信号正常Jetpack版本: sensor参数: dts配置: 分析log: 如图: EBD有两行修改dts: 测试如下:log: 需要注意极性互换查看相应的原理图设置。可以使用设备树属性lane_polarity在任何lane上配置极性交换。例如, 尝试调整极性出现花屏 根据上述像素时钟配置说明调整为如下配置后,出图正常

jzwjzw19900922的博客 1322

CF Educational Codeforces Round 15(A~D)

题目链接:http://codeforces.com/contest/702 A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are

hkh746392783的专栏 870

11、硬件工程师笔试面试——IGBT(2025版本)

IGBT的应用展望与创新趋势表明,随着电子技术的不断发展,IGBT在各个领域都有广泛的应用,如高压电力系统、交通工具、电锅炉、太阳能和风能发电系统等。FS型IGBT(场终止型绝缘栅双极晶体管)在电力传输领域的应用中,通过其独特的设计和特性,有助于确保系统的稳定性和安全性。每种器件都有其独特的优势,能够满足电力传输系统中不同的技术要求。FS型IGBT通常具有正温度系数,这意味着随着温度的升高,导通压降的主要影响因素是载流子迁移率的降低以及集电极和发射极的接触电阻的增加,有助于在高温下维持稳定的性能。

XU157303764的博客 2672

codeforces educational round 66

https://codeforces.com/contest/1175 https://codeforces.com/contest/1175/standings A:From Hero to Zero 题意:一个数k,每次可以减1,或者除以k(只有当被k整除的时候),求变为0的次数,贪心 B:Catch Overflow!相当于给了一个for的伪代码,求最后结果,结果大于 1&lt...

dezhonger的专栏 226

【路径规划】基于matlab蚁群算法机器人栅格地图最短路径规划【含Matlab源码 4590期】

基于matlab蚁群算法机器人栅格地图最短路径规划 完整代码,包运行;可提供运行操作视频!适合小白!

订阅付费专栏Matlab(奶茶价版),可赠送奶茶价版付费专栏指定代码1份; 1276

YOLOv8【第十一章:视频追踪与流处理篇·第16节】一文搞懂,DeepStream 部署入门:NVIDIA 视频分析 SDK 与 YOLOv8 结合!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏。该专栏系统复现并梳理全网各类 YOLOv8 改进与实战案例(当前已覆盖分类 / 检测 / 分割 / 追踪 / 关键点 / OBB 检测等方向),坚持持续更新 + 深度解析,质量分长期稳定在 97 分以上,可视为当前市面上 覆盖较全、更新较快、实战导向极强 的 YOLO 改进系列内容之一。

**My Coding Family** 838

cf Educational Codeforces Round 55 D. Maximum Diameter Graph

原题: D. Maximum Diameter Graph time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Graph constructive problems are back! This time the graph you ar...

@fei 510

23 RAG 为什么答不准:召回、分块、排序的常见坑

RAG 答不准时,不要先怪模型。本文把常见失败拆成召回不到、召回不准、分块不完整、排序靠后、上下文污染和生成不忠实六类,并给出从 Top-K 检查到评估集的排查流程。

老于的笔记的专栏 246

cf Educational Codeforces Round 78 D. Segment Tree

原题: D. Segment Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As the name of the task implies, you are asked to do some work with se...

@fei 391

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

cf Educational Codeforces Round 79 D. Santa's Bot

原题: D. Santa’s Bot time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has received letters from n different kids throughout this ...

@fei 442

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

cf Educational Codeforces Round 58 D. GCD Counting

原题: D. GCD Counting time limit per test4.5 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given a tree consisting of n vertices. A number is written on ea...

@fei 378

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

cf Educational Codeforces Round 56 D. Beautiful Graph

原题: D. Beautiful Graph time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given an undirected unweighted graph consisting of n vertices a...

@fei 376

codeforces Educational Round 65 ABCDF题解

昨晚刷的cf,真的是手速场啊。 A题。 大水题,看看字符串中第一个8后面(包括自己)是不是大于或等于11就行了。 1 // Cease to struggle and you cease to live 2 #include <iostream> 3 #include <cmath> 4 #include <cstdio> ...

weixin_30265171的博客 141

cf Educational Codeforces Round 134 E. Prefix Function Queries

cf 134 e kmp自动机

@fei 1875

cf Educational Codeforces Round 80 E. Messenger Simulator

E. Messenger Simulator time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp is a frequent user of the very popular messenger. He’s chatting with his friends all the time. He has n friends, n

@fei 279

cf Educational Codeforces Round 134 D. Maximum AND

cf 134d

@fei 774

codeforces educational round 32 F Connecting Vertices

F. Connecting Vertices time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output There arenpoints m...

aiba481424的专栏 113

cf Educational Codeforces Round 55 C. Multi-Subject Competition

原题: C. Multi-Subject Competition time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A multi-subject competition is coming! The competition has m ...

@fei 373

cf Educational Codeforces Round 58 C. Division and Union

原题: C. Division and Union time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output There are n segments [li,ri] for 1≤i≤n. You should divide all segmen...

@fei 416

Educational Codeforces Round 8 总结

A. Tennis Tournament time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A tennis tournament with n participants

小马的博客 971

【codeforces】【比赛题解】#920 Educational CF Round 37

【A】浇花 题意: 一个线段上每个整点都有花,有的点有自动浇花的喷水器,有问几秒能浇完所有的花。 题解: 大模拟 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #define F(i,a,b) for(int i=(a);i<=(b);++...

weixin_30687587的博客 153
上一篇: Poj 3320 Jessica's Reading Problem(尺取法)
下一篇: Poj 3279 Fliptile(反转/开关问题)
Stupid_Turtle
博客等级 码龄9年 25粉丝 18原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值