HDU 1403 Suffix Array

WRF和WPS模型在Ubuntu系统上的安装与常见问题解决指南 本文详细介绍了在Ubuntu系统上安装WRF和WPS模型的完整教程,涵盖系统环境配置、依赖库安装、源代码编译以及常见问题的解决方案。重点解决了WPS编译中intmath.f文件的修改、环境变量设置和编译器兼容性等关键难点,帮助用户高效部署气象研究与预报模型。 阅读详情
/***********************************************************************************
     用Gvim写的, 解法就是求出后缀数组后,算h值最大,并且在'#'两侧的两个串 
***********************************************************************************/
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

#define L(x) ((x) << 1)
#define R(x) ((x) << 1 | 1)
//#define ONLINE_JUDGE

typedef double LF;

const LF eps = 10e-6;

const int MAXN = 2000005;  //the max length of string
const int MAXC = 128;     //the max value of a character

char ss[MAXN], ch[MAXN];
int wa[MAXN], wb[MAXN], wv[MAXN], wc[MAXC], dp[MAXN][22];   //!!!notice wc
int rk[MAXN],h[MAXN], r[MAXN * 3], sa[MAXN * 3];
int inc[22];

int c0(int *r, int a, int b)
{
	return r[a] == r[b] && 
		r[a + 1] == r[b + 1] && 
		r[a + 2] == r[b + 2];
}
int c12(int k, int *r, int a, int b)
{
	if(2 == k)
	{
		return r[a] < r[b] || r[a] == r[b] && c12(1,r,a + 1,b + 1);
	}
	else
	{
		return r[a] < r[b] || r[a] == r[b] && wv[a + 1] < wv[b + 1];
	}
}
inline int F(int x, int tb)
{
	return x / 3 + (1 == x % 3 ? 0 : tb);
}
inline int G(int x, int tb)
{
	return x < tb ? x * 3 + 1 : (x - tb) * 3 + 2;
}
void sort(int *r, int *a, int *b, int n, int m)
{
     int i;
     for(i = 0; i < n; i++)
	 {
		 wv[i] = r[ a[i] ];
	 }
	 for(i = 0; i < m; i++)
	 {
		 wc[i] = 0;
	 }
	 for(i = 0; i < n; i++)
	 {
		 wc[ wv[i] ]++;
	 }
     for(i = 1; i < m; i++)
	 {
		 wc[i] += wc[i - 1];
	 }
     for(i = n - 1; i >= 0; i--)
	 {
		 b[ --wc[ wv[i] ] ] = a[i];
	 }
     return;
}
void dc3(int *r, int *sa, int n, int m)
{
     int i, j, *rn = r + n, *san = sa + n, ta = 0, tb = (n + 1) / 3, tbc = 0, p;
     r[n] = r[n + 1] = 0;
     for(i = 0; i < n; i++)
	 {
		 if(i % 3 != 0)
		 {
			 wa[tbc++] = i;
		 }
	 }
	 sort(r + 2, wa, wb, tbc, m);
     sort(r + 1, wb, wa, tbc, m);
     sort(r, wa, wb, tbc, m);
     for(p = 1,rn[ F(wb[0], tb) ] = 0, i = 1; i < tbc; i++)
	 {
		rn[ F(wb[i], tb) ] = c0(r, wb[i - 1], wb[i]) ? p - 1: p++;
	 }
	 if( p < tbc)
	 {
		 dc3(rn, san, tbc, p);
	 }
     else
	 {
		 for(i = 0; i < tbc; i++)
		 {
			 san[ rn[i] ] = i;
		 }
	 }
     for(i = 0; i < tbc; i++)
	 {
		 if(san[i] < tb)
		 {
			 wb[ta++] = san[i] * 3;
		 }
	 }
     if(1 == n % 3)
	 {
		 wb[ta++] = n - 1;
	 }
     sort(r, wb, wa, ta, m);
     for(i = 0; i < tbc; i++)
	 {
		 wv[ wb[i] = G(san[i], tb) ] = i;
	 }
     for(i = 0, j = 0, p = 0; i < ta && j < tbc; p++)
	 {
		sa[p] = c12(wb[j] % 3, r, wa[i], wb[j]) ? wa[i++] : wb[j++];
	 }
	 for( ; i < ta; p++)
	 {
		 sa[p] = wa[i++];
	 }
     for( ; j < tbc; p++) 
	 {
		 sa[p] = wb[j++];
	 }
     return;
}
void calheight(int *r, int *sa, int n)
{
	for(int i = 0; i < n; ++i)
	{
		rk[ sa[i] ] = i;
	}
	for(int i = 0, k = 0; i < n; ++i)
	{
		if(rk[i] == n - 1)
		{
			h[ rk[i] ] = k = 0;
		}
		else
		{
			if(k > 0)
			{
				--k;
			}
			int j = sa[ rk[i] + 1 ];
			while(r[i + k] == r[j + k])
			{
				++k;
			}
			h[ rk[i] ] = k;
		}
	}
	return ;
}
void test(int n)
{
	for(int i = 0; i < n; ++i)
	{
		printf("%d %d %d %d\n", i, sa[i], rk[i], h[i]);
	}
	return ;
}
void preprocess()
{
	inc[0] = 1;
	for(int i = 1; i < 22; ++i)
	{
		inc[i] = inc[i - 1] << 1;
	}
	return ;
}
void initRMQ(int ind)
{
	int cap = static_cast<int>( log(ind + 0.0) / log(2.0) ), mid;
	for(int i = 0; i < ind; ++i)
	{
		dp[i][0] = h[i];
	}
	for(int j = 1; j <= cap; ++j)
	{
		for(int i = 0; i + inc[j] - 1 < ind; ++i)
		{
			mid = i + inc[j - 1];
			dp[i][j] = min(dp[i][j - 1], dp[mid][j - 1]);
		}
	}
	return ;
}
int query(int x, int y) //query the minimum number between the range of h[x, y];
{
	int k = static_cast<int>( log(y - x + 1.0) / log(2.0) );
	return min(dp[x][k], dp[y - inc[k] + 1][k]);
}
void ace()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif
	int n, m;
	int maxi;
	while (gets(ss))
	{
		gets(ch);
		m = strlen(ss);
		ss[m++] = '#';
		ss[m++] = '\0';
		strcat(ss, ch);
		n = strlen(ss);
		ss[n++] = '\0';
		for (int i = 0; i < n; ++i)
		{
			r[i] = ss[i];
		}
		dc3(r, sa, n, MAXC);
		calheight(r, sa, n);
		maxi = 0;
		for (int i = 0; i < n - 1; ++i)
		{
			if (h[i] > maxi)
			{
				if (sa[i] < m && sa[i + 1] > m || sa[i + 1] < m && sa[i] > m)
				{
					maxi = h[i];
				}
			}
		}
		printf("%d\n", maxi);
	}
	return ;
}
int main()
{
	preprocess();
	ace();
	return 0;
}

嵌入式开发语言-C语言编程 C语言编程概述环境在Windows上构建C语言的环境安装在Mac上构建C语言的环境安装 概述 “C语言”被称为适合嵌入式系统开发的编程语言之一。 C语言在一般的编程中也是熟悉的开发语言,但实际上,如果试着使用C语言制作微型计算机的控制程序等,就必须使用与“普通的C程序”不同的使用方法。 作为一般的C语言的学习方法,使用“printf”“scanf”等标准函数的程序开发是固定的,但这些都是以UNIX和Windows等环境上的应用程序开发为前提的。 对此,没有显示器和键盘的嵌入式系统的微型计算机控制程序,该如何 阅读详情

相关推荐

深入解析UDS 0x19服务:DTC状态掩码与故障诊断实战

本文深入解析了UDS诊断协议中的核心0x19服务(ReadDTCInformation),重点拆解了DTC状态掩码(DTCStatusMask)的八个状态位及其在故障生命周期中的联动逻辑。通过实战案例,详细说明了从故障发生、确认到清除的全过程,并介绍了如何利用该服务进行深度诊断,包括读取扩展数据(如冻结帧)和避免常见开发误区,是理解汽车ECU故障管理机制的关键。

weixin_29248313的博客 323

codeforces EDU suffix array

suffix array的定义是一个字符串的所有后缀排序后得到的数组(下例中包括了最后的一个空串) example:string sss=ababba result:  null  a  ababba  abba  ba  babba  bba 暴力算法显然是对N个后缀直接排序,那么复杂度是不可接受的 下面通过后缀数组降低时间复杂度 定义数组ppp为排序后的后缀在原字符串sss中的位置 那么有  6 null  5 a  0 ababba  2 abba  4 ba  1 babba  3 bba 第一列即

CarolusRex的博客 569

500多种目标检测数据集下载地址汇总(YOLO、VOC)

【目标检测】红外物体检测-人、自行车、公交、小车、摩托车、骑行者、动物等15000张YOLO+VOC(含部分截取增强图).zip。【目标检测】医用个人防护装备检测数据集981张5类别(口罩、工作服、护目镜、手套、面罩检测数据集)VOC+YOLO格式.zip。【目标检测】车辆分类数据集1880张7类VOC+YOLO(含摩托车、救护车、消防车、警车、警用摩托车、轿车、大车).zip。【目标检测】隐翅虫数据集386张VOC+YOLO【目标检测】隐翅虫数据集386张VOC+YOLO【目标检测】隐翅虫数据集。

2401_85863780的博客 9162

Codeforces EDU学习之路

Codeforces的EDU学习之路 包含 Suffix Array,Segment Tree, part 1,Segment Tree, part 2,Binary Search,Disjoint Sets Union,Two Pointers Method

eyuhaobanga的博客 1387

无刷直流电机矢量控制(四):基于滑模观测器的无传感器控制

无刷直流电机矢量控制,采用转速、电流双环控制,电流环dq解耦,d轴采用id=0控制,q轴采用转速外环。采用滑模观测器(SMO),根据电压电流信息进行电机位置角度动态估算,模型可直接运行,转速和角度跟踪精度较高。 本文整理了该方法的基本原理,介绍了在MATLAB/Simulink中的建模和仿真过程,最后附上完整的模型文件。 一、基本原理 滑模观测器(下文简称SMO)是基于滑模变结构控制方法的一种状态观测器。其针对无刷直流电机转子位置估算的实现过程如下。 假设采用矢量控...

Forster-C的博客 6868

【知识点总结】电机学——原理部分

大家好,由于院校地区存在疫情没法返校,再结合当下形式,去各地旅游放松可能不是一个好的决定,o(╥﹏╥)o,期待已久的旅行就先放一边吧,但也不能闲着,既然无事,那不如继续我的总结,本次总结的内容是电机学,自九推以后我越来越明白电机学的重要性……呜呜呜~~实在太重要了,几乎所有与专业复试有关的题目都会涉及电机学,而它又比较抽象,容易使人浅尝辄止,只能理解一些表面的东西。为此自九推之后,我深刻领悟自身不足,决定对电机学发起依次猛攻,势必要将其彻底拿下,这这只是我的粗略总结,若有空闲,我将不断完善它。

weixin_51130221的博客 1万+

Suffix Array

Suffix Array Definition Let \(s\) be a string of length \(n\). The \(i\)-th suffix of \(s\) is the substring \(s[i \ldots n - 1]\). A suffix array will contain integers that represent the starti...

Vincent19999999的博客 570

OpenGL计算着色器工作组设置测试

先看看不同的显卡上工作组的数量情况。 glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, data); glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1, data + 1); glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2, data...

qq_26328385的博客 1485

CodeForces 448

A:Rewards: 题目链接:http://codeforces.com/problemset/problem/448/A 题意:Bizon有a1个一等奖奖杯,a2个二等奖奖杯,a3个三等奖奖杯,b1个一等奖奖牌,b2个二等奖奖牌,b3个三等奖奖牌,和一个有n个架子的橱柜。如今Bizon想把这些奖牌和奖杯放在橱柜里,可是要遵循以下的规则:一个架子上不能同一时候放奖杯和奖牌;一个架子上...

weixin_33895604的博客 181

Hopfield神经网络(HNN)详解

Hopfield神经网络是一种比较特殊的网络,它不像一般的神经网络那样有输入层和输出层,并且通过训练来改变神经网络中的参数,最终实现预测、识别等功能。Hopfield网络只有一群神经元节点,所有节点之间相互连接,形式如下: 虽然有些文章会画出像深度神经网络那样有输入输出的图,并且输出后又返回输入,但本质上就是多个节点之间的全连接,也就是上面的图形。Hopfield神经网络主要有两个应用:一是起到类似储存器的作用,也就是我们把多个序列或图片输入这个网络,最终这个网络会以神经元之间连接权重的形式储存这

weixin_60737527的博客 4万+

FANUC机器人S523 新款PN板卡与西门子PLC通信配置介绍

FANUC机器人S523 新款PN板卡与西门子PLC通信配置介绍

Robot_PLC_HMI_Automation 354

后缀数组(Suffix Array)

这个悲剧的东西在经历了半个月的研究后,终于研究明白了…………学会了之后突然发现,这个东西实在是太nb了~~首先还是先说一说这个东西的精髓~所谓后缀数组就是把一个整串的所有后缀的信息以一种比较高效的方式提取出来。而这种工具就是后缀数组。为什么我们偏偏选择了后缀呢?因为我们发现了了一个非常不错的现象——整个串的所有子串实际上就是所有后缀的一个个前缀。这样,几乎所有类型的字符串问题都可以变成后缀

天空の行者 4144

【PG高可用】一 PostgreSQL高可用方案repmgr部署(非常详细)

repmgr安装部署

DBA之路的博客 7056

HDU 1403(Longest Common Substring)

#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 200005; char s[MAXN]; int n; int sa[MAXN], t1[MAXN], t2[MAXN], c[MAXN], rnk[MAXN], h...

Intelligence1028的博客 137

精雕软件(JDpaint) 5.5 绿色版

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

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

【后缀数组】HDU-1403

/* 最长公共子串的问题 * * * File: main.cpp * Author: lenovo * * Created on 2011年10月18日, 上午9:01 */#include <cstdlib>#include <cstdio>#include <cstring>#define maxn 200200using namespace s...

weixin_30341745的博客 212

深度学习工具包 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")

SPOJ 1811 LCS - Longest Common Substring(后缀自动机)

传送门 题意:如题 这题其实就是SAM上跳fail的一个应用,我们一开始匹配的节点就在root,随着扔进去匹配不同的字符,我们不断的跳fail直到匹配到当前的字符,如果跳的图中pos变为-1了,即为跳回root之前的最初的未加入任何字符节点,这则表示失配,更新cnt就好了 如果找到一个pos不为-1的即匹配成功,那么我们更新cnt为len[pos]和cnt中较小的那个再加一即可(加一表示...

喵喵喵? 436

HDU 4013 图论 树的最小表示

/******************************************************************************* 去年上海赛区热身赛的一道题,树的最小表示模板题。解法就是用二进制枚举所有可能的联通子图,然后 求所有联通子图的最小表示,要注意的是对于某一个联通子图,最小表示需要枚举联通子图里的所有的点,然 后从这些点开始进行dfs,dfs过程中进

源码力量 2521

HDU 4121 模拟

/**************************************************************************************************** 坑爹的模拟题~注意这两种情况:黑方的将能直接飞过去杀了红方的将,还有将走一步能把红方别的子给吃了。。。 ******************************************

源码力量 1773

HDU 3644 计算几何 模拟退火

/* * ===================================================================================== * * Filename: hdu3644.cpp * * Description: Calculate Geometry -- Simulated annealing * *

源码力量 1742

HDU 4049 状态压缩DP

/******************************************************************************* 去年北京赛区网络赛水题,状态压缩DP,一开始TLE,然后发现是没初始化,应该用空间换时间来着, 接着WA,搞了半天没搞明白。。。最后发现发现一个小小的纰漏~~~ 解法就是建立状态dp[M][1 << N],用第一个状态表示

源码力量 1675

HDU 1512 左式堆 + 并查集

/* * ===================================================================================== * * Filename: hdu1512.cpp * * Description: Leftist Heap + Union Find Set * * Version

源码力量 1616

HDU 4036 物理坑爹题

/******************************************************************************* 坑爹的地方比较多,首先所有质量都是没用的,因为无摩擦力;其次坐标最好都用double表示;还有那个 土豆是的坐标是相对于第一个peak的坐标,第四貌似有土豆可以不在peak的范围内。。。以后找min/max值 还是用第一个元素做标记

源码力量 1590

HDU 3656 DLX重复覆盖

/********************************************************************************* 纠结了良久,这个题是DLX的重复覆盖问题,以前还没见过,最后套了晓天大牛的模板,水过了。 还是模板题。。。因为最后的答案必然是某两点的距离,所以离散化一下所有距离后二分再套用DLX 重复覆盖模板就能AC了~赞一下神函数uniq

源码力量 1565

HDU 4123 树状DP+RMQ

/****************************************************************************************************************** 尼玛。。。神题。。。居然能卡RMQ的log2的。。。解法就是先用树状DP预处理整棵树,得到每个节点距离其他节点的最大值, 这个时间复杂度是O(n),然后在得到的

源码力量 1542

HDU 4031 树状数组 区间更新及点询问

/******************************************************************************* 去年成都赛区网络赛一道题,树状数组在区间更新中的应用。树状数组一般支持的是改点,查区间,但 是这道题要求的是改区间,查点,这就要变通一下,具体可以看代码,另外要考虑的一个问题是,如何统计? 这里的处理方法就是把总共的攻击次数-防御

源码力量 1506

HDU 4046 树状数组

/******************************************************************************* WA了N多次。。。结果是忘记初始化st数组了。。。悲剧得1B。。。 解法就是考虑修改位置id的字符,观察左右"wbw"是否被更改,如果被更改了,那么就更新下,这个地方要 特别小心。。。具体可以见代码~ ************

源码力量 1410

HDU 3657 网络流

/*************************************************************************************** 去年网络赛的一道题,现在看来也不是很难。做个HDU上那道方格取数的话,这道题大致就有想法了, 但这道题有个问题是,必选点的处理,我的做法是如果该点为偶数点,则在源点与该点间建一条流量为oo 的边,如果该点为奇数点,

源码力量 1255
上一篇: HDU 2206
下一篇: HDU 4068 模拟
codeforces_sphinx
博客等级 码龄15年 32粉丝 75原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值