POJ 1204 World Puzzles

WOJ1204代码解题思路2 用栈来解决。设置两个数组,其中一个是要求输入的数组a。另一个数组b用于保存含有相同的元素的序列。 先把数组的第一个值压入栈底,在看第二个数是不是和第一个数是相同的。如果相同则进栈,否则的话栈底元素出栈继续执行。 立即下载

/*

http://acm.pku.edu.cn/JudgeOnline/problem?id=1204

第一次用Trie树,这题算是比较折腾了,遇到的问题如下
1)一开始的思路是对输入图枚举每一个位置及每一个方向插入到trie树中,然后对
每一个待搜索单词进行搜索,结果MLE
2)思考了一下如果按1)的方法插入数据量太大,MLE也是情理之中的,接着换了思路
为何不逆向来,这次是将待搜索单词插入到trie树中,然后枚举各个待搜索单词去trie
树中搜索,MLE没有了,但是又TLE,天啊,怎么回事?
3)接下来舍弃了STL的string,改为char + scanf来输入,照样TLE,看来不是输入的问题
4)紧接着仔细读了自己的程序,终于中到了一处可疑的地方.原来自己在枚举各个方向单词
的时候是先构造单词,等够咱完后再放入到trie树中搜索,但是这两个步骤是可以合二
为一的即一边构造一般搜索,这样时间大大缩小了,改完后提交就AC了,这题好汗啊,前前
后后一共交了6次
*/

#include <iostream>
#include <string>
#define MAX_N 1000
#define MAX_L 26
using namespace std;

char input[MAX_N + 2][MAX_N + 2];
int countv = 0;
int dir[8][2] = {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}};
int rowN, colN, strNum;
struct node
{
    bool v;
    int row, col;
    char dir;
}quess[MAX_N + 1];

bool inRange(int row, int col)
{
    return row >= 0 && row < rowN && col >= 0 && col < colN;
}

class TrieTree
{
protected:
    struct TrieNode;
public:
    TrieTree();
    ~TrieTree();
    int search(int row, int col, int dir) const; //0:not found; 1:found
    void insert(char indexStr[], int index);
protected:
    struct TrieNode
    {
        int index;
        TrieNode *branch[MAX_L];
        TrieNode();
    };
    TrieNode *root;
};

TrieTree::TrieTree()
{
    root = NULL;
}
TrieTree::~TrieTree()
{
    delete root;
    root = NULL;
}
TrieTree::TrieNode::TrieNode()
{
    index = -1;
    for(int i = 0; i < MAX_L; i++)
        branch[i] = NULL;
}
void TrieTree::insert(char indexStr[], int index)
{
    char c;
    int indexPos = 0;
    if(root == NULL)
        root = new TrieNode();
    TrieNode *curNode = root;
    for(indexPos = 0; indexPos < strlen(indexStr); indexPos++)
    {
        c = indexStr[indexPos];
        if(curNode->branch[c - 'A'] == NULL)
            curNode->branch[c - 'A'] = new TrieNode();
        curNode = curNode->branch[c - 'A'];
    }
    curNode->index = index;
}
int TrieTree::search(int row, int col, int d) const
{
    char c;
    int indexPos = 0, curRow = row, curCol = col;
    if(root == NULL)
        return 0;
    TrieNode *curNode = root;
    while(inRange(curRow, curCol))
    {
        c = input[curRow][curCol];
        if(curNode->branch[c - 'A'] == NULL)
            return 0;
        curNode = curNode->branch[c - 'A'];
        if(curNode->index != -1)
        {
            if(!quess[curNode->index].v)
            {
                countv++;
                quess[curNode->index].row = row;
                quess[curNode->index].col = col;
                quess[curNode->index].dir = d + 'A';
                quess[curNode->index].v = true;
            }
        }
        if(countv == strNum)
            return 1;
        curRow = curRow + dir[d][0];
        curCol = curCol + dir[d][1];
    }
    return 1;
}


void search(TrieTree *tt)
{
    int i, j, d;
    string temp;
    for(i = 0; i < rowN; i++)
    {
        for(j = 0; j < colN; j++)
        {
            for(d = 0; d < 8; d++)
            {
                tt->search(i, j, d);
                if(countv == strNum)
                    return;
            }
        }
    }
}
int main()
{
    int i;
    cin>>rowN>>colN>>strNum;
    TrieTree *tt = new TrieTree();
    for(i = 0; i < rowN; i++)
        scanf("%s", input[i]);
    char input[MAX_N + 2];
    for(i = 0; i < strNum; i++)
    {
        scanf("%s", input);
        tt->insert(input, i);
    }
    search(tt);
    for(i = 0; i < strNum; i++)
        cout<<quess[i].row<<" "<<quess[i].col<<" "<<quess[i].dir<<endl;
    return 0;
}

百元DIY手机荧光计:低成本荧光检测平台搭建与实战 荧光检测是一种基于物质受特定波长光激发后发射更长波长荧光的分析技术,其核心原理在于光与物质的相互作用。通过选择性激发与检测,该技术能实现对痕量物质的高灵敏度、高特异性定量分析,在生物医学、环境监测和食品安全等领域具有重要价值。传统荧光分光光度计虽精度高,但成本昂贵、体积庞大且操作复杂,限制了其在现场快检和普及教育中的应用。本文聚焦于如何利用智能手机的高性能摄像头和处理器,结合低成本光学滤光片和LED光源,构建一个便携、经济的DIY荧光检测平台。该方案通过简化光路设计,采用带通滤光片进行波长选择,并利用图像处 阅读详情

相关推荐

西门子200SMART自定义库开发实战:从PID到露点算法的工业应用

本文详细介绍了西门子200SMART自定义库开发实战,涵盖从PID控制到露点算法的工业应用。通过代码封装技巧、多语言支持和性能优化等高级开发方法,帮助工程师提升PLC编程效率。文章特别强调了自创库在实际项目中的优势,如恒温恒湿控制系统的成功案例,展示了自定义库在工业自动化中的强大应用价值。

lake5的博客 1025

Poj 1204 简单AC自动机

题目链接:http://poj.org/problem?id=1204   题意:给出一个字符方阵和一系列字符串,试从方阵中找出字符串出现的位置,方阵中字符串按八个方向查询。   将待查询字符串插入字典树,构造AC自动机,然后对方阵的四条边,每条边对应的三个方向进行查询。

dooder_daodao的专栏 1386

视频倍速 - 在线调倍速的加速器APP工具

一刀工具箱APP提供一键可将手机上的视频倍速播放,可以调整视频倍速的加速器,调节视频的速度也就是调节视频的播放速度!一键可将手机上的视频倍速播放,可以调整视频倍速的加速器,调节视频的速度也就是调节视频的播放速度!视频倍速-在线调倍速的加速器-一刀工具箱APP。...

无涯教程 7555

poj 1204 字符串处理 多串匹配自动机

View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<stdlib.h> 4 #define N 1010 5 struct node 6 { 7 node *next[26]; 8 node *fail;...

Andy20141210的博客 164

2.1 量子精密测量:SERF原子陀螺仪中的核自旋-电子自旋强耦合机制

本文深入解析了SERF原子陀螺仪中核自旋-电子自旋强耦合机制的核心原理与应用。通过量子精密测量技术,SERF陀螺仪实现了超高精度的惯性导航,其独特的磁场自补偿和拉莫尔进动特性使其在弱磁场环境下表现出色。文章还探讨了关键技术突破和前沿进展,展示了量子精密测量在惯性导航领域的巨大潜力。

kotlin6android的博客 210

Leaflet 加载天地图完整配置指南:从插件修改到无限缩放(附源码)

本文详细介绍了Leaflet与天地图深度集成的完整配置指南,包括插件修改、无限缩放实现及源码示例。通过解析天地图服务的WMTS协议、双投影支持和密钥机制,帮助开发者突破缩放级别限制,优化地图应用性能,适用于Web地图开发和高精度GIS系统。

weixin_27180827的博客 441

poj1204(AC自动机,模板)

题意:给个L*C的字符串矩阵,W个询问,对每个询问输出这个串第一次出现的位置及方向,共有8个方向,用A~H表示 思路:其实就是普通的AC自动机,但由于有八个方向,所以要把各种方向的可能性都给试一遍。注意,由于要记录开始字符串,所以在构造tire树的时候就应该把那些字符串倒过来构造,切记。 #include&lt;cstdio&gt; #include&lt;cstring&gt; #incl...

qq_39861441的博客 560

SMART200如何实现多次调用子程序带定时器功能

1、西门子200PLC的子程序由于很多限制条件,如果希望建立一个可以多次调用的子程序,那么这个子程序里是不能含有定时器指令的,所以我们只能退而求其次了。建议将沿指令(上升沿、下降沿)放在多次调用子程序的外面。 2、可以提供不同的时基,提供不同时间的定时 3、实现秒定时 5、子程序内部: STL代码: 1、时基信号由外部提供、 可以提供不同的时基信号 2、实现循环定时开关 LD #Start:L0....

RXXW_Dor的博客 1万+

poj 1204 (AC自动机)

#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define PB push_back #define SIZE(

__夜 962

论文必备 - YOLOv13热力图可视化,支持指定模型,指定显示层,设置置信度,以及10种可视化实现方式

本文带来的是YOLOv13热力图可视化功能,支持,以及。我们经常看到一些论文里绘制了不同的热力图,一方面能够直观的感受其模型的有效性,另一方面也丰富了论文内容。特别是在使用了注意力模块的网络中,热力图就可以验证注意力机制是否真正聚焦到了预期的重要特征上,以便对模型的有效性和合理性进行评估。例如这篇文章中展示的,就很能够表达作者改进后的模型相比之前模型的优越性。

Limiiiing的博客 488

Altium Designer(AD24/25)如何在PCB设计阶段做阻抗匹配

目前阻抗匹配多直接有制版厂进行,PCB设计师在设计阶段可不关注阻抗设计,在加工阶段只需标注需要控制的阻抗线,制板厂即可按照要求对阻抗线进行调整和控制。但是对于设计师来讲掌握阻抗线的设计方法也是非常必要的。本文介绍Altium Designer(AD24/25)如何在PCB设计阶段做阻抗匹配。

fydar的博客 893

poj 1204 Word Puzzles

题目来源:http://poj.org/problem?id=1204

Abner 1万+

NVIDIA Isaac Sim 入门教程(一)

文档分为以下几个部分: 简介、安装指南、API 文档、教程、手册和参考资料。简介部分是对 Omniverse Isaac Sim 的基本概述,以及它如何融入 NVIDIA Omniverse™ 生态系统。它还概述了 Omniverse Isaac Sim 的架构、工作流程和文档布局。

机器人控制与仿真应用 1万+

POJ 1204-Word Puzzles解题报告

确实是一道字符串好题,用AC自动机做的,不过思路比较简单,并且AC自动机还要加一些优化,要找的是串是否出现在了模式串中,这样有很多位置不用去比较,比如说,要考虑一行的时候,这一行的子串就不用再次验证了,因为出现在了这一行的一部分中一定会出现在整个这一行中的,这样能减少处理时间 View Code 1 #include <iostream> 2 #inclu...

weixin_30767835的博客 153

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

POJ 1204 【AC自动机】

开始wa掉了,360行的代码找错真难受!!!居然是一个地方多减了一个1…… #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #ifdef _WIN32 #define

量子流逝 693

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

POJ-1204 Word Puzzles

用了字典树+枚举,如果先枚举出二维数组所有可能的情况用字典树存起来会超空间,只能用字典树存要查的串,然后枚举各个点作为起点的各个方向的串是否存在要查的串。十分感谢poj评论区中一个大佬提供的数据生成程序,找出了trie数组开小的错误,我还是菜。 #include <cstdio> #include <cstring> using namespace std; const int N = 1e3 + 5; const int NN = 1e6 + 5; char s[N][N], d[

qq_25243147的博客 171

IDEA的使用指南

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

【字典树】 poj1204 Word Puzzles

Word Puzzles http://poj.org/problem?id=1204 Description Word puzzles are usually simple and very entertaining for all ages. They are so entertaining that Pizza-Hut company started using tab

Ted's 游乐园 2917

Poj1204

题目大意:给你一个字母表格,问你在这些字母表格中是否存在下面所给的字符串,如果存在的话给出字符串首字母的起始坐标,已经搜寻方向。 算法思路:一开始直接暴力深搜,从每个满足条件的首字母开始,递归8个方向,结果超时,于是去学习了字典树。如果不明白什么是字典树,可自行了解,网上的很多博客都有详细的介绍和实现代码。后来对于这道题,我发现字典树快就快在如果一个字符串是另一个字符串的前缀,直接深搜要找两遍...

huyifan1的博客 289

POJ1204

Problem : Word Puzzles Description : 给你一个矩阵的字母,然后再给你一些单词,让你求这些单词在矩阵中的位置。 Solution : 字典树+深搜。其实循环都可以,没必要深搜,但是深搜写起来简单,也过了。这个题我们要颠覆下字典的概念,按照我们之前的观念,这个矩阵中的字母就是字典。但是这样,工作量将会非常大,我们要枚举所有矩阵中所有可能的单词,然后建字典树。但是如

FlushHip 750

POJ 1204 AC自动机的初步认识+模板题

前一向在搞字典树就是为了搞AC自动机...AC自动机的用处..或者说最一般的用处就是给一个字典..找一篇文章中哪些单词出现过的一种较优的方法...而AC自动机的结构或者说方法简单的说就是字典树+KMP...首先将字典中的所有单词构造一颗字典树(我前面的文章有详细的介绍字典树..这里就不说了)...然后再类似KMP的方法来给每个点构造Fail指针..而在用AC自动机在文章中查找中的过程很类似KMP在

zzyzzy12 4259

poj1204之AC自动机

AC自动机

Stephen 1936

POJ 1204 AC自动机

点击打开链接 题意:给个L*C的字符串矩阵,W个询问,对每个询问输出这个串第一次出现的位置及方向,共有8个方向,用A~H表示 思路:用AC自动机进行快速匹配,细节处理特别多,不看题解的话应该会WA很多次,还有一个处理的非常巧妙地地方,就是我们要输出第一次出现的位置,而AC自动机不能回溯,所以将串反着构造进字典树里,真是神犇,然后方向设置时也反着就可以了#include #include #

Dan__ge的博客 4990

【POJ1204】Word Puzzles——AC自动机

Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 10594 Accepted: 4002 Special Judge DescriptionWord puzzles are usually simple and very entertaining for all ages. They are

绝尘 841

poj 1204 Word Puzzles (AC自动机)

题目链接:   poj 1204 题目大意:   给出字典,再给出n个单词                   找出这些单词在单词表的什么位置,以什么顺序排放(8个方向,A表示正北,顺时针方向依次为B ~ H) 解题思路:   由于字典太大,若以字典的所有单词建立字典树空间复杂度很高                   建立n个单词的字典树和失败指针              

ンZee的解题报告 1808

【POJ】1204 Word Puzzles

题目链接:https://vjudge.net/problem/POJ-1204 Description Word puzzles are usually simple and very entertaining for all ages. They are so entertaining that Pizza-Hut company started using table covers ...

Phantom_stars的博客 462

【网易有道10年编程赛 资格赛第一场】 第二题 有道搜索框

描述在有道搜索框中,当输入一个或者多个字符时,搜索框会出现一定数量的提示,如下图所示:现在给你N个单词和一些查询,请输出提示结果,为了简化这个问题,只需要输出以查询词为前缀的并且按字典序排列的最前面的8个单词,如果符合要求的单词一个也没有请只输出当前查询词。 输入 第一行是一个正整数N,表示词表中有N个单词。接下来有N行,每行都有一个单词,注意词表中的单词可能有重复,请忽略掉重复单词。所有的单词都由小写字母组成。接下来的一行有一个正整数Q,表示接下来有Q个查询。接下来Q行,每行有一个单词,表示一个查

bobten2008的专栏 1712
上一篇: POJ 1200 Crazy Search
下一篇: POJ 1177 PICTURE
bobten2008
博客等级 码龄18年 153粉丝 157原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值