POJ3320---Jessica's Reading Problem(尺取法)

Python 爬虫实战:爬取 B 站 UP 主的全部视频数据 本文详细介绍了基于Python开发B站UP主视频数据爬虫的技术方案。通过分析B站API接口,使用requests库发送HTTP请求并处理JSON数据,结合pandas进行结构化存储。文章重点解决了接口鉴权、分页爬取、反爬策略等核心难点,实现获取视频标题、播放量、点赞数等关键指标。同时强调数据爬取需遵守平台规范,仅限技术研究使用。该方案为B站视频内容分析提供了可靠的数据采集基础,具有实际应用价值。 阅读详情

Description

Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas included in a very thick text book. The author of that text book, like other authors, is extremely fussy about the ideas, thus some ideas are covered more than once. Jessica think if she managed to read each idea at least once, she can pass the exam. She decides to read only one contiguous part of the book which contains all ideas covered by the entire book. And of course, the sub-book should be as thin as possible.

A very hard-working boy had manually indexed for her each page of Jessica’s text-book with what idea each page is about and thus made a big progress for his courtship. Here you come in to save your skin: given the index, help Jessica decide which contiguous part she should read. For convenience, each idea has been coded with an ID, which is a non-negative integer.

Input

The first line of input is an integer P (1 ≤ P ≤ 1000000), which is the number of pages of Jessica’s text-book. The second line contains P non-negative integers describing what idea each page is about. The first integer is what the first page is about, the second integer is what the second page is about, and so on. You may assume all integers that appear can fit well in the signed 32-bit integer type.

Output

Output one line: the number of pages of the shortest contiguous part of the book which contains all ideals covered in the book.

Sample Input

5
1 8 8 8 1

Sample Output

2

Source
POJ Monthly–2007.08.05, Jerry

找到一个最短的序列,包含整个序列中所有不同的数
思路:尺取法+map记录

/*************************************************************************
    > File Name: POJ3320.cpp
    > Author: ALex
    > Mail: zchao1995@gmail.com 
    > Created Time: 2015年03月30日 星期一 21时01分42秒
 ************************************************************************/

#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#include <set>
#include <vector>

using namespace std;

const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double eps = 1e-15;
typedef long long LL;
typedef pair <int, int> PLL;

const int N = 1000010;
map <int, int> mp;

int arr[N];

int main()
{
    int n;
    while (~scanf("%d", &n))
    {
        int all = 0;
        mp.clear();
        for (int i = 1; i <= n; ++i)
        {
            scanf("%d", &arr[i]);
            if (mp.count(arr[i]) == 0)
            {
                ++all;
                mp[arr[i]] = 1;
            }
        }
        mp.clear();
        int ans = inf;
        int s = 1, e = 1;
        int cnt = 1;
        mp.clear();
        mp[arr[1]] = 1;
        while (s <= n && e <= n)
        {
            while (e < n && cnt < all)
            {
                ++e;
                if (mp[arr[e]] == 0)
                {
                    ++cnt;
                    mp[arr[e]] = 1;
                }
                else
                {
                    ++mp[arr[e]];
                }
            }
            if (cnt >= all)
            {
                ans = min(ans, e - s + 1);
            }
            --mp[arr[s]];
            if (mp[arr[s]] == 0)
            {
                --cnt;
            }
            ++s;
        }
        printf("%d\n", ans);
    }
    return 0;
}
133、神经渲染与AI RAW:从RAW域到sRGB的端到端学习 去年在调试某款旗舰手机的主摄时,遇到一个让人头疼的问题——夜景模式下,暗部细节虽然保留得不错,但色彩总是偏紫,而且高光边缘有诡异的“水彩感”。ISP的3A统计跑了几十版,降噪强度从0调到100,甚至把去马赛克算法换成了自适应方向插值,问题依旧。后来团队里一位做AI的同事说:“要不试试端到端?从RAW直接出sRGB。”当时我第一反应是“这玩意儿能稳定吗?”结果试了一版,偏紫消失了,高光边缘的伪影也没了。从那以后,我开始认真研究神经渲染与AI RAW这条路线。 阅读详情

相关推荐

基于深度残差U-Net与多尺度注意力机制的医学图像分割系统

本文提出了一种创新的医学图像分割系统,通过融合残差连接、通道注意力机制和空间金字塔池化技术,构建了高性能的UResnet分割网络。系统采用编码器-解码器架构,创新性地引入多层次特征增强模块,显著提升了医学图像中复杂组织结构的分割精度。实验结果表明,该方案在多个医学图像数据集上均取得了优异性能,边界分割精度提升15%,训练收敛速度提升30%,同时减少20%计算量。系统为临床诊断提供了可靠的技术支持,未来可扩展至3D医学图像分割和联邦学习等方向。

Henry的博客 814

Jessica‘s Reading Problem(尺取法)

Jessica’s Reading Problem (尺取法) Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas included in a very thick tex

Anthcony的博客 613

ROS自定义地图实战:从CAD到导航的完整流程

本文详细介绍了如何将CAD图纸或手绘草图高效转换为ROS机器人可直接使用的导航地图。通过解析PGM与YAML标准格式,提供从图像处理、尺度校准到集成AMCL与move_base导航栈的完整实战流程,帮助开发者跳过繁琐的SLAM建图,实现快速、精准的自定义地图部署。

weixin_29083475的博客 496

Jessica's Reading Problem(尺取法)

Jessica’s Reading Problem Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she ha...

一直努力 429

SAP CO-PA数据传送避坑指南:销售开票与FI/MM记账的日常配置实操(含KEKF/KE4I/KEI2)

本文深入解析SAP CO-PA数据传送中的常见配置问题,特别是销售开票与FI/MM记账环节的实操避坑指南。通过KEKF/KE4I/KEI2等关键配置点的详细说明,帮助用户避免数据失真和重复记录,提升获利能力分析的准确性。文章结合实战案例,揭示官方文档未提及的'数据黑洞'形成机制,为SAP顾问提供实用的排雷手册。

weixin_26905487的博客 391

家庭路由器从入门到精通:连接设置、优化排障全指南

路由器作为家庭网络的核心枢纽,其工作原理基于NAT(网络地址转换)和DHCP(动态主机配置协议)两大关键技术。NAT负责将公网IP转换为多个内网IP,实现多设备共享上网;DHCP则自动为接入设备分配IP地址,简化网络配置。这些技术共同构建了稳定、安全的局域网环境,其价值在于为智能家居、在线办公、高清影音和游戏娱乐等场景提供可靠的网络基础。理解路由器的物理连接、后台设置与故障排查逻辑,是优化Wi-Fi信号覆盖、提升网络性能、保障家庭网络安全的关键。本文以路由器配置与排障为核心,详细解析从WAN/LAN口区分、

weixin_33393017的博客 406

Jessica's Reading Problem

题目: Jessica's Reading Problem ( POJ No.3320 ) 为了准备考试,Jessica 开始读-本很厚的课本。要想通过考试,必须把课本中所有的知识点都掌握。这本书总共有P页,第i页恰好有一个知识点ai; (每个知识点都有一个整数编号)。全书中同一个知识点可能会被多次提到,所以她希望通过阅读其中连续的一些页把所有的知识点都覆盖到。给定每页写到的知识点,请求出...

qq_1300258993的博客 695

想在 Visual Studio Code 里进行 ABAP 开发,需要安装的扩展列表

安装完毕后,我们可以将 SAP 系统配置为 Visual Studio Code 连接的远程文件系统。为了连接到 SAP 系统,需要启用 ABAP 开发工具 (ADT) ICF 节点,这与 SAP Hana Studio 等工具使用的服务相同。打开 SAP GUI 并连接到目标系统,运行事务 SICF,然后激活 ADT_SRV 服务,如下所示。这启用了允许代码编辑器和 IDE 连接到 SAP 系统的服务。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 3123

Jessica's reading problem

问题描述如下: Jessiac 读一本P页的书, 第i页恰好记录了知识点ai(每个知识点都有一个整数标号), 书中同一个知识点可能会出现多次。 Jessica希望通过阅读书中的连续的页数, 并且能够覆盖掉所有的知识点。 试着确定Jessica要阅读的最少页数。 限制条件: 1 程序如下: #include #include #include #include #include

a130737的专栏 1009

如何给K8S配置一个具有永久有效的kubeconfig

在 Amazon EKS 环境中,Kubernetes 的认证机制与 AWS IAM 深度集成,通过aws-iam-authenticator动态生成临时凭证。这种设计虽然增强了安全性,但给需要持久化凭证的工具链(如 CI/CD 系统中的 KubeVela)带来了挑战。具体表现为:临时凭证失效​​:默认 Token 有效期为 15 分钟至 1 小时;​​IAM 角色限制​​:直接使用aws eks get-token生成的凭证无法持久化

小杨同学的博客 660

​​10.3 时间敏感网络(TSN)协议适配​

本文探讨了时间敏感网络(TSN)协议在PCIe网络加速卡开发中的适配方案,重点分析了时间同步、流量调度和冗余传输三大核心问题。研究从协议实现、硬件加速设计和驱动优化三个维度展开,提出采用FPGA实现PTP时钟同步、动态TAS调度器以及双路径冗余传输等技术方案。通过工业控制网络案例验证,该方案将端到端延迟从120μs降至8μs,带宽利用率提升至92%,同时实现了100%的确定性保障。研究还总结了调试工具和典型问题解决方法,为TSN在PCIe网络中的实际应用提供了技术参考。

amy_mhd的博客 364

Jessica's Reading Problem POJ - 3320

Jessica's Reading Problem  POJ - 3320  Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to ...

Willen_的博客 277

NVIDIA Jetson之远程控制软件NoMachine安装使用

参考:https://www.bilibili.com/video/BV1cg4y1i776?t=12 0 背景

ZONGXP的博客 1万+

poj3320Jessica's Reading Problem—尺取法(java)

题目链接 大意:给序列数字,找出最小子序列,包含所有的元素类型。例如 5 1 8 8 8 1 输出2,因为1 8就包含了所有元素 思路:尺取法 这个和裸的尺取优点不同的是,他需要一个map来维护判断而不是sum维护判断。在右侧从左向右遍历的同时,用一个map<Integer,Integer>来维护元素,map.keyset()就可以判断是否包含所有元素,数值用来判断改元素出现次数是否...

bigsai 3023

WINCC7.3破解文件

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

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

POJ3320 Jessica's Reading Problem 尺取法

题目链接:http://poj.org/problem?id=3320 题目大意:一本书上有n个知识点,这本书一共有p页,每页一个知识点(每个知识点有一个唯一的整数编号),全书中同一知识点可能会被多次提到,现在希望通过阅读其中连续的一些页码把所有的知识点都覆盖到。给出每页写到的知识点,求出最少需要阅读的页数。 分析:我们假设从某一页(第s页)开始阅读,为了覆盖所有的知识点需要阅

AC_Gibson的专栏 567

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

POJ 3320 Jessica's Reading Problem 尺取法

Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18385   Accepted: 6360 Description Jessica's a very lovely girl woo...

pxlsdz的博客 464

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

POJ - 3320 Jessica's Reading Problem(尺取法)

题意:为了准备考试,Jessica开始读一本书,书总共有P页,第i页有一个知识点ai,同一个知识点可能会出现多次,她希望读书中一段连续的页数来掌握所有的知识点,请求出需要读的最少的页数。 分析:我们用尺取法来求解。 (1).初始化s=t=num=0。 (2).如果t小于P,且num小于n(所有知识点个数),就一直增加t,如果出现新的知识点,则num++。 (3).如果num小于n,退出。否则更新res。 (4).count[s]--,如果这个知识点不再有出现,则num--,s++。回到(2)。

luciozhang的博客 1527

POJ 3320 Jessica's Reading Problem 【尺取法】

Jessica's Reading Problem Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to

博客已搬迁到http://www.cnblogs.com/cniwoq/ 278

POJ 3320 · Jessica's Reading Problem【尺取法】

尺取法,难度中等。

张天枭の博客 459

poj3320 Jessica's Reading Problem 尺取法

http://poj.org/problem?id=3320 #include &lt;iostream&gt; #include &lt;algorithm&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;set&gt; #include &lt;map&gt; using namespace std; c...

skykone1的博客 210

Jessica's Reading Problem(POJ3320【尺取法】)

Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas incl...

ZepngLin的博客 317

POJ3320 Jessica's Reading Problem 尺取法

Jessica’s Reading Problem、 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22716 Accepted: 7687 Description Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem....

lifehappy 349

[尺取法] poj3320 Jessica's Reading Problem

Jessica’s Reading Problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8531 Accepted: 2732 DescriptionJessica’s a very lovely girl wooed by lots of boys. Recently she has a pr

童凌的技术博客 656

poj 3320 Jessica's Reading Problem 【尺取法+STLmap set】

Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7893   Accepted: 2529 Description Jessica's a very lovely girl wooed by lots of

世界很大 1060

POJ3320 Jessica's Reading Problem【尺取法】

  Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12441   Accepted: 4234   Description Jessica's a very lovely girl wooed by lots of boys. Re...

海岛Blog 1441

Jessica's Reading Problem POJ - 3320(尺取法)

Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas incl...

starlet_kiss的博客 330
上一篇: Codeforces Round #116 (Div. 2, ACM-ICPC Rules)---E. Cubes
下一篇: POJ1743---Musical Theme(后缀数组+二分)
tokers
博客等级 码龄12年 71粉丝 700原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值