武大校赛资格赛 最小矩阵覆盖

本文探讨了一个贪心算法解决方案,用于快速满足森林中连续树懒群体的需求。通过选择最优矩形区域覆盖树懒,实现最小化喂食时间。详细分析了算法策略、时间复杂度和实例应用。
Problem 1567 - D - Sloth's Angry
Time Limit: 1000MS   Memory Limit: 65536KB   
Total Submit: 248  Accepted: 88  Special Judge: No
Description
A forest is full of sloths, they are so eager for tree leaves and as a result, very angry.
We assume that the forest is a map of N * M grids, and each of the gird is an empty land or contains a big sloth. It’s guaranteed that the sequence of the sloth is a continuous segment from the leftmost column for every row. ( You may consider that the number of columns M is infinite ).
As a sloth lover, you want to feed all the sloths as quick as possible. Every second you may select a rectangle area of the grids which only contains sloths and feed all the sloths there.
What’s the minimum time required to meet all the sloths’ needs in the forest?
Input
First line of each case contains one numbers N.(1≤  n ≤ 1 000).

The following line contains N numbers Ai, each describing the length of continuous sloths sequence from the left most column in every row. ( 1 <= Ai <= 10^9 )
Output
Output the answer on a single line for each case.
Sample Input
4
3 4 5 5
Sample Output
3
Hint

The distributing situation of the sloths in the sample is as follow:

SSS

SSSS

SSSSS

SSSSS

And you can choose three rectangles to cover it.

 

恩。很显然的贪心,证明如下:

设还未选择的子矩阵,即剩下的步骤中的最优解,组成了一个集合,每次尝试确定这个集合中左端点最小的一个矩阵,并把它从集合里删去。

这样我们可以发现,某行树懒是否被完全喂饱,取决于当前选择的矩阵是否包含该行的最右边的端点。换句话说,如果不包含这个最右边的端点,那么我们称这次的操作对该行树懒并不产生实质影响。

如此,显然可以得到一个贪心策略:每次选择整个区间中每行右端点中最小的值,并利用一次操作去掉这些行。然后继续划分下去。

#include<algorithm>
#include<iostream>
#include<limits.h>
#include<stdlib.h>
#include<string.h>
#include<cstring>
#include<iomanip>
#include<stdio.h>
#include<bitset>
#include<cctype>
#include<math.h>
#include<string>
#include<time.h>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>

#define LL long long

using namespace std;
const LL mod = 1e9 + 7;
const double PI = acos(-1.0);
const int M = 1005;

int a[M];

LL work(int l, int r, int x)
{
    int last = l, mn = a[l];
    LL len = r - l + 1, sum;
    for(int i = l; i <= r; ++i)
        mn = min(mn,a[i]);
    sum = 1;
    for(int i = l; i <= r; ++i){
        if(a[i] == mn){
            if(last < i)
                sum += work(last,i - 1,mn);
            last = i + 1;
        }
    }
    if(last <= r)
        sum += work(last,r,mn);
    return min(len,sum);
}
int main()
{
    int n;
    while( cin >> n ){
        for(int i = 1; i <= n; ++i)
            scanf("%d",&a[i]);
        int flag = 2;
        for(int i = 2; i <= n; ++i){
            if(a[i] == a[i - 1])
                continue;
            a[flag++] = a[i];
        }
        LL ans = work(1,flag - 1,0);
        cout << ans << endl;
    }
    return 0;
}


 

内容概要:本文围绕“基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究”展开,提出了一种结合Koopman算子理论与递归神经网络(RNN)的数据驱动建模方法,旨在对非线性纳米定位系统进行有效线性化建模,并实现高精度的模型预测控制(MPC)。该方法利用Koopman算子将非线性系统映射到高维线性空间,通过递归神经网络学习系统的动态演化规律,构建可解释性强、计算效率高的线性化模型,进而提升预测控制在复杂不确定性环境下的鲁棒性与跟踪精度。文中给出了完整的Matlab代码实现,涵盖数据预处理、网络训练、模型验证与MPC控制器设计等环节,具有较强的基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究(Matlab代码实现)可复现性和工程应用价值。; 适合人群:具备一定控制理论基础和Matlab编程能力的研究生、科研人员及自动化、精密仪器、机器人等方向的工程技术人员。; 使用场景及目标:①解决高精度纳米定位系统中非线性动态响应带来的控制难题;②实现复杂机电系统的数据驱动建模与预测控制一体化设计;③为非线性系统控制提供一种可替代传统机理建模的有效工具。; 阅读建议:建议结合提供的Matlab代码逐模块分析实现流程,重点关注Koopman观测矩阵构造、RNN网络结构设计与MPC控制器耦合机制,同时可通过替换实际系统数据进行迁移验证,深化对数据驱动控制方法的理解与应用能力。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值