unique snowflakes (uva 11572)

【代码超详解】UVA 11572 Unique Snowflakes 独特的雪花(unordered_set,130 ms) 一、题目描述 某公司通过一种机器将若干雪花打包并售卖。机器一旦开始工作,就不能停止,直到进入的雪花都被封入一个包装。 输入的第一行是测试样例的数量。每个测试样例的首行是一个数 n ,代表接下来进入机器的雪花。每个正整数代表一个雪花,范围从 0 到 1e9(包含)。如果出现多个相同的数字,那么这些雪花是相同的。雪花的数量不超过 1 百万。 对每个样例,输出一个数,代表一个包装中最大的不同雪花数量。 ... 阅读详情

Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a
machine that captures snowflakes as they fall, and serializes them into a stream of snowflakes that flow,
one by one, into a package. Once the package is full, it is closed and shipped to be sold.
The marketing motto for the company is “bags of uniqueness.” To live up to the motto, every
snowflake in a package must be different from the others. Unfortunately, this is easier said than done,
because in reality, many of the snowflakes flowing through the machine are identical. Emily would like
to know the size of the largest possible package of unique snowflakes that can be created. The machine
can start filling the package at any time, but once it starts, all snowflakes flowing from the machine
must go into the package until the package is completed and sealed. The package can be completed
and sealed before all of the snowflakes have flowed out of the machine.
Input
The first line of input contains one integer specifying the number of test cases to follow. Each test
case begins with a line containing an integer n, the number of snowflakes processed by the machine.
The following n lines each contain an integer (in the range 0 to 109
, inclusive) uniquely identifying a
snowflake. Two snowflakes are identified by the same integer if and only if they are identical.
The input will contain no more than one million total snowflakes.
Output
For each test case output a line containing single integer, the maximum number of unique snowflakes
that can be in a package.
Sample Input
1
5
1
2
3
2
1
Sample Output
3
题意:找一段最长的连续子序列,要求子序列内没有重复的元素
思路:尺取 + set 判重 , 设端点 L , R ,初始化其值分别为0 1,并将第一个元素加入集合,然后让R一直往后扫描,看是否集合内是否存在,若存在,则使得L在不超过R的情况下直接向前走(因为R在扫描时已经判定了其除开当前R的元素的子序列合法故符合题意),边走边从集合中删除当前 L 所对应的字符,若走到与 R 不同的地方就继续让 R 扫描,期间随时更新最大选择的区间长度。

 int main()
  {
    int n;
      cin >> n;
        while (n--)
        {
          int m;
            int L = 0 , R = 1;
             int maxn = 1;
           vector<int> v;
             set<int> SET;
            scanf("%d",&m);
              for(int i = 0 ; i < m ; ++ i) v.push_back(read());
               SET.insert(v[0]);
              while( R < m )
              {
                    while( SET.count(v[R]) && L < R) SET.erase(v[L]) , L++;
                     SET.insert(v[R]);
                       maxn = max(( R - L + 1),maxn);
                        R++;
              }
            printf("%d\n",maxn);
        }
  }

Centos7安装NVIDIA驱动并在docker容器中使用GPU 阅读详情

相关推荐

【Ablation Studies 理解】深度学习模型组件的对比实验/性能分析

Ablation Study 用于检测深度学习/机器学习模型中各部分构件对于整体的重要性。 可以理解为为:组件\tricks重要性测试、组件性能系统性分析、控制变量法、组件去除对比实验、性能敏感性测试、性能因子分析等 Ablation Studies 一些新颖的深度学习模型在论文中都会进行AblationStudy,这部分的主要意义在于系统性的移除模型中的各种组件/trick等因子或者是创新的...

TomRen 4594

Unique Snowflakes

Unique Snowflakes Description Problem A: Unique Snowflakes Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a machine that captures

岁月蒙尘 1089

5分钟搞懂MSDNet:用Transformer实现小样本语义分割的保姆级教程

本文详细介绍了MSDNet(Multi-Scale Decoder Network)如何利用Transformer架构实现小样本语义分割。通过多尺度解码器和空间Transformer解码器,MSDNet能够在仅有1-5张标注图像的情况下完成精确分割任务。文章提供了PyTorch代码实例和优化技巧,帮助开发者快速掌握这一前沿技术。

weixin_30832143的博客 510

uva 11572 Unique Snowflakes (唯一的雪花)

题目链接题意输入一个长度为n 的序列,找到一个尽量长的连续子序列Al~Ar,使得该序列中没有相同元素。 分析 用左右端点去遍历 然后用set查重。#include<bits/stdc++.h> using namespace std; int a[1000005],len,l,r,t,n; int main (void){ ios::sync_with_stdio(false);

努力努力再努力 649

柴油机高压共轨电控系统:从硬件架构到控制逻辑的深度解析

发动机电控系统是现代内燃机的核心技术,它通过传感器网络实时采集发动机状态,由电控单元(ECU)依据复杂的控制算法和MAP图进行决策,最终驱动执行器实现精准控制。其核心价值在于实现了动力性、经济性与排放性能的协同优化。在柴油机领域,高压共轨电控系统是这一原理的典型应用,它将燃油喷射压力与发动机转速解耦,通过建立恒定的高压油轨,并利用ECU对喷油量、喷油正时及喷油压力进行毫秒级闭环控制,从而显著提升燃烧效率并降低污染物排放。该系统广泛应用于追求高扭矩、低油耗的商用车及非道路机械中,其硬件架构涵盖低压油路、高压油

weixin_42709044的博客 316

构建基于知识图谱的金融风险关联网络可视化系统

知识图谱是一种用于表示实体及其关系的图形结构,能够将分散的数据组织成易于理解和查询的形式。语义性:通过实体和关系的描述,赋予数据语义。结构化:以图的形式组织数据,便于计算机处理。动态性:支持实时更新,能够反映数据的最新状态。风险关联网络是指将金融风险事件、实体及其关系以图形形式表示的网络。关联性:能够展示风险事件之间的相互影响。动态性:能够实时反映风险变化。可视化:便于金融从业者直观理解风险分布。可视化系统是指通过图形界面展示数据或信息的系统。提供直观的数据显示。帮助用户快速理解复杂数据。

AI天才研究院 1070

集训第三周

没有思路的时候,想想要不要预排序或前缀和,或先前缀和然后预排序。

clmm_的博客 273

OpenClaw 超级 AI 实战专栏【实战案例】(五)邮件收发 + 日历日程 + 文件管理一站式搞定

OpenClaw 实现办公自动化核心是模块解耦:邮件收发、文件管理、日历日程各自封装,便于维护和扩展;开发中需重点解决编码兼容、权限配置、时间格式、重复处理四大类坑点,核心思路是 “提前校验 + 异常兜底 + 统一格式”;敏感信息(邮箱密码、API Token)务必通过.env管理,避免硬编码泄露。

qq_36130719的博客 757

UVA 11572 唯一的雪花 Unique Snowflakes

UVA 11572 Unique Snowflakes

阿巴阿巴 450

Microsemi Libero系列教程(四)——PLL的使用

文章目录PLL是什么Libero中PLL的使用官方文档 系列教程:Microsemi Libero系列教程 PLL是什么 PLL(Phase Locked Loop): 为锁相回路或锁相环,用来统一整合时钟信号,使高频器件正常工作,如内存的存取资料等。PLL用于振荡器中的反馈技术。 许多电子设备要正常工作,通常需要外部的输入信号与内部的振荡信号同步。一般的晶振由于工艺与成本原因,做不到很高的频率...

whik1194的博客 7224

Android BSP 开发深度解析:驱动开发、系统定制与调试实战

本文系统介绍了Android BSP开发的核心技术要点,重点探讨了外设驱动开发与调试方法。文章首先解析了Android系统分层架构和BSP的关键作用,详细阐述了Linux内核驱动开发基础,包括字符设备、平台设备和输入子系统驱动的实现方法。随后针对触摸屏、WIFI、蓝牙、USB、摄像头和屏幕等常见外设,深入分析了驱动开发要点和调试技巧。此外,还梳理了Android系统启动流程,介绍了常用调试工具和方法论,并提供了面试常见问题及参考答案。全文内容全面实用,为Android底层开发人员提供了系统的技术指南。

郑伟强dev的专栏 312

Unique Snowflakes UVA - 11572

#include <iostream> #include <bits/stdc++.h> using namespace std; vector<int>a; set<int>S; int main() { int T,n; int num; cin>>T; while(T--) { ...

剑似生平 245

YOLOv5基于深度学习的道路缺陷检测系统

然而,由于长期的自然侵蚀、车辆磨损等因素,道路表面容易出现裂缝、坑洼等缺陷。这些缺陷不仅会影响驾驶舒适性,还可能引发交通事故,尤其是在恶劣天气或夜间行车条件下。随着人工智能技术的快速发展,基于深度学习的道路缺陷检测技术能够在降低人力成本的同时提高检测效率,为道路维护提供了新的解决方案。本项目构建了基于YOLOv5的道路缺陷检测系统,结合PyQt5开发了用户友好的UI界面,具备实时检测和图片分析功能。工具对图片进行标注,生成YOLO格式的标注文件。上传包含道路裂缝或坑洼的图片,系统会标注出缺陷的位置及类别。

YOLO 1078

uva 11572 Unique Snowflakes

题目大意:求给定序列的最大连续的各个数字不同的序列长度。 解题:此题不是难题,就是使用一个hash表来查找在前面是否存在一个数与当前的相等,如果相等就将左边的边界设为相等的数的pos+1,再将当前的数加入hash表中,唯一注意的点就是在hash查找的时候注意判断左边的下界就行了。 // // main.cpp // uva 11572 - Unique Snowflakes

最爱她! 322

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

解题报告 之 UVA11572 Unique Snowflakes

解题报告 之 UVA11572 Unique Snowflakes Description Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a machine that captures snowflakes

JUST CODE 1129

WINCC7.3破解文件

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

[UVA11572]Unique Snowflakes[构造]

题目链接:[UVA11572]Unique Snowflakes[构造] 题意分析:就是给你一堆雪花的大小序列。问在这样的序列中,最长的没有重复数字的序列有多长? 解题思路:从小到大遍历,每次记录下独一无二的数字的下标,有新的独一无二的数字加入就把当前序列长度更新,如果当前序列长度大于找到的最大的,就更新。如果碰到相同的就跳到相同的那个的下一个进行查找。标记下标我使用了map映射。 个人感受

闲停 659

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

uva 11572 Unique Snowflakes

#include<iostream> #include<algorithm> #include<queue> #include<cmath> #include<math.h> #include<string> #include<string.h> #include<map> #include<unordered_map> #include<unordered_set> #includ...

qq_35752161的博客 192

UVa OJ 11572 - Unique Snowflakes

UVa OJ 11572 - Unique SnowflakesProblem输入一个长度为n(n≤106)的序列A,找到一个尽量长的连续子序列AL~AR,使得该序 列中没有相同的元素。InputThe first line of input contains one integer specifying the number of test cases to follow. Each test c

Yuuki_Dach's Blog 698

《UVA11572 唯一的雪花 Unique Snowflakes》

Emily 的公司的口号是“把独特打包起来”,为了实现这一诺言,一个包裹里不能有两片一样的雪花。Emily 想知道这样一个不包含两片一样的雪花的包裹最大能有多大,她可以在任何时候启动机器,但是一旦机器启动了,直到包裹被封上为止,所有通过机器的雪花都必须被打包进这个包裹里,当然,包裹可以在任何时候被封上。第一行是测试数据组数 T,对于每一组数据,第一行是通过机器的雪花总数 n(n≤106),下面 n 行每行一个在 [0,109] 内的整数,标记了这片雪花,当两片雪花标记相同时,这两片雪花是一样的。

Jasmine_llq的博客 492

[UVa 11572] 唯一的雪花(Unique Snowflakes)

Judge:https://vjudge.net/problem/UVA-11572 题意:在一个长度最多为10^6的序列中找到一个尽量长的、没有相同元素的连续子序列。

StarlitNight的博客 682

UVA 11572 Unique Snowflakes(滑窗|双指针)

UVA 11572 Unique Snowflakes(https://vjudge.net/problem/UVA-11572)题意一个长度为n的序列A,找到一个尽量长的连续子序列,并且该序列中没有相同元素解决 以区间来思考这个问题,让右指针不断增加,增加到一个不能增加(冲突)的位置 当无法延伸右指针,也就是说A[right]在A[left,right-1]这段出现过,此时增大左指针 我们增加左指

ZhangYang 553

Uva 11572 Unique snowflakes

比较简单的一道题目,一边遍历数据一边记录已经遍历的数据,同时在遍历的时候还要判断该数据是否之前已经被遍历过,如果被遍历过,那么就将该数据以及之前已经遍历到的数据清除,同时要注意记录遍历的数据的最大的长度,最后输出结果即可,具体实现见如下代码: #include #include #include #include #include #include #include #include #incl

zju2016的博客 267

UVA 11572 Unique Snowflakes .

题目地址:http://vjudge.net/problem/UVA-11572 第一种用set做 #include using namespace std; #define REP(i,a,b) for(int i=a;i<=(int)(b);++i) #define REPD(i,a,b) for(int i=a;i>=(int)(b);--i) int A[(int)1e6+5];

BRCOCOLI的博客 338

uva 11572 unique snowflakes

题目大意:输入一个长度为n(n 方法:使用set容器中的count,insert,erase三个函数,将序列扫一遍,当前的元素与序列中的元素不相同,就添加进序列,否则,删除序列最左边的元素。 提醒:我是在vjudge上交的题,在hdu交就wa,在uva交就ac,不知道原因,希望大家也不要为此困惑。 AC代码: #include #include #include #include #inc

meizhouyihei的专栏 416

[UVA - 11572] Unique Snowflakes (尺取法)

Link https://vjudge.net/problem/UVA-11572 Description  给定一个含nnn个整数的序列aaa,求出一种元素最多含一个的最大区间(即区间内每种元素只出现一次的最大区间),该区间不一定含出现的所有元素。 Solution  考虑用指针维护一个每种元素只含一个的区间,同时用int记录所出现最大区间,需要用到数组cntcntcnt,记录维护区间内的每个数...

梧桐 294

uva 11572 ——Unique Snowflakes

题意:给定一个序列,然后在这个序列找到一个连续的串,使得串中没有重复的元素。 思路:单调队列。每次都把该在序列没出现的数加入到序列中,然后向后扫描找到最大的ans。 code: //#incllude //#include #include #include using namespace std; const int N=1000005; int v[N]; in

坚持不懈 431
上一篇: 暑假集训-8.3总结
下一篇: B - Vile Grasshoppers (codeforces)
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值