POJ 1631 Bridging signals

别再死记硬背了!用STM32CubeMX+FreeRTOS API实战一个智能小车项目(附避坑指南) 本文通过STM32CubeMX+FreeRTOS API实战智能小车项目,详细解析了从CubeMX配置到多任务协同的实现过程。重点介绍了FreeRTOS在实时控制、传感器数据处理及任务间通信中的应用,并提供了避坑指南和性能优化技巧,帮助开发者高效掌握嵌入式RTOS开发。 阅读详情

Bridging signals
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 6001 Accepted: 3285

Description

'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports of two functional blocks cross each other all over the place. At this late stage of the process, it is too expensive to redo the routing. Instead, the engineers have to bridge the signals, using the third dimension, so that no two signals cross. However, bridging is a complicated operation, and thus it is desirable to bridge as few signals as possible. The call for a computer program that finds the maximum number of signals which may be connected on the silicon surface without crossing each other, is imminent. Bearing in mind that there may be thousands of signal ports at the boundary of a functional block, the problem asks quite a lot of the programmer. Are you up to the task? 

A typical situation is schematically depicted in figure 1. The ports of the two functional blocks are numbered from 1 to p, from top to bottom. The signal mapping is described by a permutation of the numbers 1 to p in the form of a list of p unique numbers in the range 1 to p, in which the i:th number specifies which port on the right side should be connected to the i:th port on the left side.Two signals cross if and only if the straight lines connecting the two ports of each pair do.

Input

On the first line of the input, there is a single positive integer n, telling the number of test scenarios to follow. Each test scenario begins with a line containing a single positive integer p < 40000, the number of ports on the two functional blocks. Then follow p lines, describing the signal mapping:On the i:th line is the port number of the block on the right side which should be connected to the i:th port of the block on the left side.

Output

For each test scenario, output one line containing the maximum number of signals which may be routed on the silicon surface without crossing each other.

Sample Input

4
6
4
2
6
3
1
5
10
2
3
4
5
6
7
8
9
10
1
8
8
7
6
5
4
3
2
1
9
5
8
9
2
3
1
7
4
6

Sample Output

3
9
1
4

Source

 

/*

http://acm.pku.edu.cn/JudgeOnline/problem?id=1631
DP+二分查找
一开始没有使用二分查找,时间复杂度是n ^ 2,结果超时
后来改用二分,时间复杂度是nlgn,AC
二分的思路是:
使用bsVal来保存当前长度的序列中最小的point位置
比如bsVal[2] = 3意味着,长度为二的序列中最小的位置是3
*/

#include <iostream>
#define maxv(a, b) ((a) >= (b) ? (a) : (b))
#define MAX_N 40000
using namespace std;

int maxData[MAX_N + 1];
int input[MAX_N + 1];
int maxP;
int bsVal[MAX_N + 1];

void binarySearch(int curPos)
{
    int l = 1, r = maxP, mid;
    while(l <= r)
    {
        mid = (l + r) / 2;
        if(bsVal[mid] < input[curPos])
            l = mid + 1;
        else
            r = mid - 1;
    }
    maxData[curPos] = l;
    bsVal[l] = input[curPos];
    maxP = maxv(maxP, l);
}
int main()
{
    int caseNum, pNum, i, j;
    scanf("%d", &caseNum);
    for(i = 1; i <= caseNum; i++)
    {
        maxP = 1;
        scanf("%d", &pNum);
        for(j = 1; j <= pNum; j++)
        {
            scanf("%d", &input[j]);
            maxData[j] = 1;
            if(j == 1)
            {
                bsVal[1] = input[j];
                continue;
            }
            binarySearch(j);
        }
        printf("%d/n", maxP);
    }
    return 0;
}

STM32F407+FreeRTOS平衡小车工程框架搭建指南 嵌入式实时系统开发中,多任务协同与硬件资源精准配置是保障控制稳定性的核心。基于STM32F407的智能平衡小车项目,典型融合了FreeRTOS任务调度、时钟树配置、外设驱动封装与任务间同步机制等关键技术。其本质是将高实时性控制(如200Hz传感器采集)、中频算法执行(100Hz PID)与低频人机交互(5Hz OLED显示)解耦为独立任务,并通过合理分配优先级、栈空间与同步原语(队列/信号量)实现确定性运行。该框架不仅适用于平衡小车,更是电机控制、姿态稳定、移动机器人等实时嵌入式系统的通用工程范式,为后续算 阅读详情

相关推荐

STM32F411智能循迹小车完整工程:FreeRTOS多任务调度+CubeMX图形化配置+HAL驱动

基于STM32F411RE主控芯片的智能循迹小车控制工程,开箱即用,支持红外或灰度传感器实时巡线、十字路口识别、黑白块判别、路径偏离自动纠偏及任务完成后自动返程。整个项目采用STM32CubeMX生成初始化代码,基于HAL库开发,集成FreeRTOS实现多任务管理,包含任务调度(Task)、消息队列(Queue)、信号量(Semaphore)等核心组件。工程结构清晰,含标准Keil MDK-ARM项目文件(.uvprojx、.uvoptx)、CMSIS与HAL驱动层、硬件抽象层(HardWare)、传感器驱

transformer2023的博客 416

基于STM32手把手教你做FreeRTOS平衡小车

此平衡小车基于STM32F401CCU6制作,在FreeRTOS下运行,能够完成直立,在手机蓝牙调试APP控制下能够前后运动以及转动。基于STM32手把手教你做FreeRTOS平衡小车。

qq_16627473的博客 7038

win2016 php mysql_Windows Server 2016 IIS10.0+PHP(FastCGI)+MySQL环境搭建教程 | 系统运维...

准备篇一、环境说明:操作系统:Windows Server 2016PHP版本:php 7.1.0MySQL版本:MySQL 5.7.17.0二、相关软件下载:1、PHP下载地址:2、MySQL下载地址:3、Microsoft Visual C++ 2010 可再发行组件包(安装MySQL需要此插件)4、Visual C++ Redistributable for Visual Studio 20...

weixin_34794420的博客 1377

STM32F1、FreeRTOS、PID平衡小车

摘要:本文介绍基于STM32F103C8T6的两轮平衡小车实现方案。系统采用MPU6050传感器获取俯仰角,通过互补滤波融合加速度计和陀螺仪数据。控制采用双环PID结构,内环为角度环保持直立,外环为速度环实现稳定移动,并加入转向环控制差速。针对低速电机特性,重点讨论了PID参数调节技巧,包括目标值限幅、积分限幅等措施。文章详细分析了各控制环的相互作用关系,并指出电机转速对系统性能的关键影响,为低速电机条件下的平衡车实现提供了实用解决方案。

zkabcd1234的博客 492

STM32 ST-LINK Utility 无法烧录程序的解决方法

当你打开STM32 ST-LINK Utility,硬件连接好st-link V2,打开了要烧写的文件,点那个Program verify烧录时, 如果出错了: Programming error @ 0x08000000! 我的方法是: 点你想要烧录那个HEX文件的小格,复制 然后去到你前面的文件的格子里,点粘贴: 成功! ...

wocute的博客 9521

Kali Linux下John the Ripper实战:从识别yescrypt哈希到破解zip压缩包(保姆级避坑指南)

本文详细介绍了在Kali Linux中使用John the Ripper工具从识别yescrypt哈希到破解zip压缩包的全过程。针对常见的'No password hashes loaded'报错,提供了两种解决方案,并扩展讲解了哈希识别、zip文件破解及性能优化技巧,是安全测试人员的实用指南。

weixin_29323365的博客 236

Bridging signals POJ - 1631

'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports ...

Qtt110的博客 298

OFDR解调全同弱反射光纤阵列

全同弱反射光纤光栅阵列是在一根光纤上密集刻写波长相同的WFBG,由于每个光栅的反射都比较弱,可实现一根光纤上复用成千上万个光栅,阵列上每个光栅栅区长度相同,相邻光栅之间栅距相同,呈周期性分布。2、获取测量信号:对弱栅阵列加载状态下,使用OFDR系统再次获取弱栅时域曲线,为测量信号。(这里需要注意的是对弱栅阵列加载后,不能使弱栅中心波长漂移到激光器波长扫描范围之外,若超出范围则OFDR技术不能获取弱栅反射信号,因此在选择弱栅阵列波长时尽量让其中心波长在激光器波长扫描范围中间,确保温度/应变测量范围。

m0_69386663的博客 1955

poj 1631 Bridging signals

Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12333   Accepted: 6736 Description 'Oh no, they've done it again', cries the chief designer

Jazz_Charles的博客 444

学习笔记【Day 20】鸿蒙PC应用在SD WAN MSTP场景用CodeArts test工具测试过程

多生成树协议(MSTP)作为二层网络高可靠、无环路的核心技术,其在鸿蒙 PC 上的兼容性与稳定性测试尤为重要。本文结合华为云 CodeArts TestPlan 全流程测试管理平台,详细拆解鸿蒙 PC 端 MSTP 功能的测试设计、环境搭建、执行验证。1.测试左移,保障迭代效率CodeArts TestPlan 将 MSTP 测试从后期集成阶段 “左移” 至开发早期,通过可复用用例库与自动化脚本,支持每次代码提交后的快速回归测试,避免网络功能稳定性因迭代被破坏。2.平台化工具破解复杂场景测试难题。

aiyijianghe的博客 1058

GBase8a-GDCA认证考试-复习参考题

为提升产品服务水平定期举办GBase产品认证培训,培训更多GBase数据库专业人员,满足用户快速成长的业务需求,建设GBase产品生态。请注意甄别,根据所学知识综合判断,正确率97%(97分)。

weixin_41826637的博客 2373

POJ-1631 Bridging signals

'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports ...

XYBDX的博客 192

萤石云cs刷机解绑固件

萤石CS-C2C-32WFR刷机包,萤石CS-C6TC刷机包,萤石CS-C6H刷机包,萤石猫眼产品等等。萤石云摄像头固件修改,绑定手机号解绑,更换序列号教程。

海康威视技术支持 2万+

poj1631 Bridging signals

Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14087   Accepted: 7619 Description 'Oh no, they've done it again', cries the chief designe

樱花满地集于我心,楪舞纷飞祈愿相随 331

【C++】【STL算法】数据窄化及代码安全性

本文系统探讨了C++工程中数据窄化(narrowing conversion)的隐患与解决方案。数据窄化指将高精度/大范围类型转换为低精度/小范围类型,虽语法合法但会导致静默精度损失。其危险性体现在:错误隐蔽、STL会放大问题、数值错误具有传播性。现代C++要求窄化必须显式声明,文中提出四种工程解决方案:显式转换、边界统一转换、范围检查转换和使用GSL工具。建议在系统边界集中处理窄化,保持计算链路类型一致性,并通过分层策略(建模用double,控制用float)确保数值稳定性。核心思想是让窄化成为清晰可控的

Double Galaxy 80

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

POJ - 1631 Bridging signals

最长上升子序列LIS解法

The Blog Of Uncle_Sugar 458

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

POJ1631 Bridging signals

解答:#include using namespace std;int psearch(const int f[],int size,const int a) {     int l = 0,r = size-1;     while(l<=r)     {         int mid = (l+r)/2;         if (a>=f[mid-1]&&a<f[mid]) return m

Rainto的专栏 557

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Bridging signals 【POJ - 1631】

'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports ...

Meant_To_Be的博客 251

poj 1631 Bridging signals

题意:题目太长了,模模糊糊终于知道这是个求最长上升子序列的题目。开始果断用以前的方法((0(n^2)),果断TLE(n 思路:其实自己思路就不怎么清楚。这算法利用二分法减少搜索时间,二分法利用了序列的单调性。但是内部的运行步骤还是不清楚(和背包问题一样)……自己慢慢琢磨啊。 代码: #include #include #include #define INF 0x7FFFF

Paradiser 686

POJ - 1631 Bridging signals

'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports ...

GJLfly的博客 246
上一篇: POJ 1961 Period
下一篇: POJ 1157 LITTLE SHOP OF FLOWERS
bobten2008
博客等级 码龄18年 153粉丝 157原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值