poj3080Blue Jeans

poj-3080 blue jeans Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth 阅读详情

题目链接:http://poj.org/problem?id=3080
求给定多个字符串的最长公共子串,若有相同输出字典序最小的那个
因为每个串最多60个字符,枚举其中一个串的子串进行匹配并记录最大值即可。

#include <stdio.h>
#include<cstring>
#include<string>
using namespace std;
char ans[70];
char a[12][70],b[70];
int la[12],lb,lans;
int nxt[70];
void gnx(){
    memset(nxt,0,sizeof(nxt));
    int i=0,j=-1;
    nxt[0]=-1;
    while(i<lb){
        if(j==-1||b[i]==b[j])nxt[++i]=++j;
        else j=nxt[j];
    }
}
int kmp(int no,int llb){
    int i=0,j=0;
    while(i<la[no]&&j<llb){
        if(j==-1||a[no][i]==b[j])i++,j++;
        else j=nxt[j];
    }
    if(j==llb)return 1;
    return 0;
}
int les(char bb[],int len){
    int flag=0;
    if(len>lans)return 1;
    if(len<lans)return 0;
    for(int i=0;i<len;i++){
        if(bb[i]<ans[i])return 1;
        if(bb[i]>ans[i])return 0;
    }
    return 0;
}
int main(void)
{
    int t;
    scanf("%d",&t);
    while(t--){
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%s",a[i]);
            la[i]=strlen(a[i]);
        }
        lans=0;
        for(int i=0;i<la[1];i++){
            strcpy(b,a[1]+i);
            lb=la[1]-i;
            gnx();
            for(int j=1;j+i<=la[1];j++){
                int flag=1;
                for(int k=2;k<=n;k++){
                    if(!kmp(k,j)){
                        flag=0;
                        break;
                    }
                }
                if(flag){
                    if(les(b,j)){
                        for(int k=0;k<j;k++){
                            ans[k]=b[k];
                        }
                        ans[j]=0;
                        lans=j;
                    }
                }
            }
        }
        if(lans>=3)printf("%s\n",ans);
        else puts("no significant commonalities");
    }
    return 0;
}

其实这个写的慢了。。。只需要枚举开头匹配,然后边匹配边更新就好了,复杂度会低一个级别,早期写的懒得改了。。。

[poj 3080]Blue Jeans [kmp] Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth w 阅读详情

相关推荐

OpenStack 8 节点生产级高可用(HA)集群实施文档

本文详细介绍了生产级高可用OpenStack集群的架构设计与实施方案。通过采用3节点控制集群(HAProxy+Keepalived)、2节点计算资源池和3节点Ceph分布式存储,实现了控制平面、计算资源和存储系统三个层面的高可用。方案重点阐述了VIP漂移、MariaDB Galera集群、RabbitMQ镜像队列等关键组件的配置方法,并提供了完整的部署流程和故障验证方案。该架构确保任意单节点故障不会影响平台整体可用性,满足生产环境对稳定性、扩展性和可维护性的要求,为构建无单点故障的OpenStack生产环境

彭大帅的博客 780

POJ_3080 Blue Jeans 【KMP】

题目链接 题目描述 题目叭叭说了一大堆,其实意思就是让你在n个字符串中找到一个最长的公共子串,如果长度小于3输出:no significant commonalities 否则输出最长的子串即可。 解题思路 首先将第一个串分解,把其所有的子串作为kmp的模式串,在剩余的字符串中查找,如果剩余的字符串中都存在该模式串,就更新答案(公共子串的长度 和 公共子串)。 最后根据题目...

Learning Deep Learning 478

别再只盯着meta包了!盘点R语言中7个元分析工具包的特色与适用场景

本文深入评测了R语言中7个主流元分析工具包(meta、metafor、netmeta、mada、mvmeta、metasens、rmeta)的核心功能与适用场景,帮助研究者根据具体需求精准选型。通过对比表格和实际代码示例,详细解析了各工具包在传统两两比较、网络Meta分析、诊断准确性研究等不同场景下的差异化优势,并提供了性能对比和组合使用建议。

weixin_30736301的博客 296

POJ 3080.Blue Jeans

题目:http://poj.org/problem?id=3080 AC代码(C++): #include #include #include #include #include #include #include #include #include #define INF 0xfffffff #define MAXN 2005 using namespace

njyexiong的博客 260

SPSS中的数据分析—信度效度检验【1】

前一段时间跟大家分享了好几篇关于EXCEL方面的数据分析知识,不知道大家都掌握得怎么样了。今天咱们换个口味,给大家讲一下关于SPSS中的数据分析——信度效度检验。 现阶段正处在毕业季阶段,很多同学可能都正在忙着去弄自己的论文和答辩(不知道大家在翟天临上热搜这个事情上有没有做出过一定贡献),很多时候我们在写论文答辩甚至于其他课题研究的时候都会选择用问卷这种形式来收集数据。最后我们只需要针对问卷所取...

小白数据营的博客 6万+

三维视觉智能焊接系统:免示教技术的工业应用实践

本文深入探讨了三维视觉智能焊接系统中免示教技术的工业应用实践。该系统通过三维视觉相机实时扫描工件,自动识别焊缝并生成轨迹,将产线换型时间从数小时缩短至几分钟,显著提升了生产柔性。文章详细解析了其核心硬件、算法及工厂部署流程,并展望了与数字孪生、工艺智能化融合的未来趋势。

weixin_29091105的博客 431

POJ - 3080 Blue Jeans

https://vjudge.net/problem/POJ-3080 POJ - 3080 Blue Jeans题目AC代码 题目 The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth was p

斯文~ 260

zemax 如何编译用户自定义DLL(含VS下载教程)

zemax 如何编译用户自定义DLL(含VS下载教程)

weixin_72050316的博客 491

POJ 3080 Blue Jeans

Blue Jeans Time Limit:1000MS Memory Limit:65536K Total Submissions:22483 Accepted:9983 Description The Genographic Project is a research partnership between IBM and The Natio...

~ 449

SAP Gateway 中事务码 /IWFND/MAINT_SERVICE 的用法介绍

本文系统梳理了SAP Gateway中/IWFND/MAINT_SERVICE事务码的核心功能与运维实践。作为OData服务管理中樞,它支持服务注册激活、ICF节点配置、系统别名绑定、批量处理等关键操作。文章详解了服务目录、ICF节点、系统别名的配置要点,提供了批量激活、缓存清理、性能监控等实用技巧,并针对常见陷阱(如传输配置、删除残留)给出解决方案。通过制造业批量激活、零售业OAuth集成等案例,展示了事务码在企业级应用中的实际价值,为SAP Gateway运维提供了一套完整的治理清单。

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

基于Simulink的电气弹簧ES稳压控制模型仿真

在本文中,我们将使用Simulink建立一个ES稳压控制系统的模型,并通过仿真验证其性能。接下来,我们配置了各个组件的参数,包括电源电压、负载电流以及ES和控制器的传递函数。通过调整模型中的参数和控制算法,我们可以进一步优化系统的性能并实现更好的电压稳定调节。该系统通过对电力系统中的ES进行控制,调整其阻尼特性,以实现对电压的稳定调节。例如,我们可以设置电源的电压值、负载的电流值,以及控制器的参数(如PID控制器的比例、积分和微分增益)。反馈控制可以根据测量值来调整控制器的输出,从而实现对电压的稳定调节。

DevProZ的博客 421

POJ 3080 Blue Jeans

POJ 3080 Blue Jeans Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to ma...

旺崽的博客 2586

【Python】-- 趣味代码 - 发牌游戏

Python -- 趣味代码 - 发牌游戏

银尘博客 351

poj 3080 Blue Jeans

题意:输入N个DNA序列,每个DNA序列长度都为60。找到这些串的最长共有子序列。 注:若找不到,或最长子序列长度小于2,则输出no significant commonalities,否则输出最长公共子串,若长度相同输出字典序最小的 思路:暴力枚举第一个DNA序列的每一个子序列,用strstr()函数与其余的序列进行匹配

happy_lcj 1287

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

POJ 3080 Blue Jeans KMP

题目:http://poj.org/problem?id=3080 题意:给定m个字符串,长度都为60,且只有ACGT四种字符,问这m个串的最长公共串是什么,若有多个,输出字典序最小的那个,长度小于3的输出no significant commonalities 思路:枚举第一个字符串的,每次去掉首部一个字符,然后用kmp去匹配剩下的所有字符串,求得所有公共长度的最小值,然后取其中的最大值,记

弱智就要多努力 496

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

poj 3080 Blue Jeans(kmp)

poj 3080 PKU 3080 Blue Jeans(kmp)?#include<stdio.h>#include<string.h>const int N=100;int n,m,next[N];char dna[N][N];void get_next(char *str,int len){ next[0]=-1; int j=0,k=-1;//k记...

weixin_30498921的博客 75

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

[POJ3080]Blue Jeans 【String】

[POJ3080]Blue Jeans 【题目大意】 给你M个字符串,每个字符串长度为60,让你选出最长且字典序最小的一段,始这个子串是这M个字符串的子串,如果最长子串长度<3,输出“no significant commonalities”,否则输出这个子串。 【题解】 其实没啥好写,就是,字符组串的运用,其实不需要KMP,...

aiweiluan5095的博客 121

POJ-3080 Blue Jeans

题意:在给出的所有串中找出一个长度大于三且字典序最小的最长模式串并输出,否则输出no significant commonalities。 思路:如果存在模式串,则该模式串可成功匹配到所有串,枚举出第一个串的全部子串作为模式串,与其他串进行匹配。 #include <cstdio> #include <cstring> using namespace std; char s[15][65], p[65]; int next[65], lp, ls, flag; void get_ne

qq_25243147的博客 228

【KMP+二分枚举】 I - Blue Jeans POJ - 3080

Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21193   Accepted: 9399 Description The Genographic Project is a research partnersh...

博客 267

POJ3080-Blue Jeans

http://poj.org/problem?id=3080 最长公共子串,感觉自己写的不错~ #include<stdio.h> #include<string.h> const int maxm=10+2; const int maxs=60+2; int main(void) { int loop,m,len,i,j,k; ch...

weixin_30466953的博客 90

POJ 3080, Blue Jeans

brute force用第一个字符串从长到短生成所有的子串, 并和其他字符串匹配。 DescriptionThe Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousan...

weixin_34101229的博客 250

POJ 3080 Blue Jeans kmp

一、内容 The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth was populat...

Tizzi的博客 1421

【POJ3080】Blue Jeans

这道题我们发现每个串的长度只有60 所以对于第一个串(或者选一个你喜欢的)枚举子串分别与其他串KMP匹配 注意长度相等时字典序最小&&长度<3时no significant commonalities 1 #include<cstdio> 2 #include<cstring> 3 using namespace s...

diefou0453的博客 115
上一篇: poj2752Seek the Name, Seek the Fame
下一篇: hdu2594Simpsons’ Hidden Talents
IDrandom
博客等级 码龄12年 31粉丝 125原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值