青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

poj1204

Word Puzzles

Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 6968 Accepted: 2651 Special Judge

Description

Word puzzles are usually simple and very entertaining for all ages. They are so entertaining that Pizza-Hut company started using table covers with word puzzles printed on them, possibly with the intent to minimise their client's perception of any possible delay in bringing them their order.

Even though word puzzles may be entertaining to solve by hand, they may become boring when they get very large. Computers do not yet get bored in solving tasks, therefore we thought you could devise a program to speedup (hopefully!) solution finding in such puzzles.

The following figure illustrates the PizzaHut puzzle. The names of the pizzas to be found in the puzzle are: MARGARITA, ALEMA, BARBECUE, TROPICAL, SUPREMA, LOUISIANA, CHEESEHAM, EUROPA, HAVAIANA, CAMPONESA.

Your task is to produce a program that given the word puzzle and words to be found in the puzzle, determines, for each word, the position of the first letter and its orientation in the puzzle.

You can assume that the left upper corner of the puzzle is the origin, (0,0). Furthemore, the orientation of the word is marked clockwise starting with letter A for north (note: there are 8 possible directions in total).

Input

The first line of input consists of three positive numbers, the number of lines, 0 < L <= 1000, the number of columns, 0 < C <= 1000, and the number of words to be found, 0 < W <= 1000. The following L input lines, each one of size C characters, contain the word puzzle. Then at last the W words are input one per line.

Output

Your program should output, for each word (using the same order as the words were input) a triplet defining the coordinates, line and column, where the first letter of the word appears, followed by a letter indicating the orientation of the word according to the rules define above. Each value in the triplet must be separated by one space only.

Sample Input

20 20 10
QWSPILAATIRAGRAMYKEI
AGTRCLQAXLPOIJLFVBUQ
TQTKAZXVMRWALEMAPKCW
LIEACNKAZXKPOTPIZCEO
FGKLSTCBTROPICALBLBC
JEWHJEEWSMLPOEKORORA
LUPQWRNJOAAGJKMUSJAE
KRQEIOLOAOQPRTVILCBZ
QOPUCAJSPPOUTMTSLPSF
LPOUYTRFGMMLKIUISXSW
WAHCPOIYTGAKLMNAHBVA
EIAKHPLBGSMCLOGNGJML
LDTIKENVCSWQAZUAOEAL
HOPLPGEJKMNUTIIORMNC
LOIUFTGSQACAXMOPBEIO
QOASDHOPEPNBUYUYOBXB
IONIAELOJHSWASMOUTRK
HPOIYTJPLNAQWDRIBITG
LPOINUYMRTEMPTMLMNBO
PAFCOPLHAVAIANALBPFS
MARGARITA
ALEMA
BARBECUE
TROPICAL
SUPREMA
LOUISIANA
CHEESEHAM
EUROPA
HAVAIANA
CAMPONESA

Sample Output

0 15 G
2 11 C
7 18 A
4 8 C
16 13 B
4 15 E
10 3 D
5 1 E
19 7 C
11 11 H

Source


基本多串匹配
給定一個(gè)字母矩陣
在給定一些單詞,問(wèn)這些單詞在矩陣中的位置和方向,
囧呆了,單詞構(gòu)建trie樹(shù),
把矩陣中的每一個(gè)8個(gè)方向之一的字符串看作文章
然后去做自動(dòng)機(jī)
只需要枚舉周?chē)蝗Φ狞c(diǎn)的方向即可(想了好久才明白,自己去琢磨),

看來(lái)自己對(duì)ac自動(dòng)機(jī)還不是理解的很透徹,得再看幾遍

#include <cstdio>
#include 
<cstdlib>
#include 
<cstring>
#include 
<cmath>
#include 
<ctime>
#include 
<cassert>
#include 
<iostream>
#include 
<sstream>
#include 
<fstream>
#include 
<map>
#include 
<set>
#include 
<vector>
#include 
<queue>
#include 
<algorithm>
#include 
<iomanip>
#define maxn 1005
using namespace std;
int n,m,w;
char s1[maxn][maxn];
char str[maxn];
int dx[8][2]={{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};
struct node
{
    
int next[26];
    
int count;
    
int fail;
    
void init()
    
{
        memset(next,
-1,sizeof(next));
        count
=0;fail=0;
    }

}
s[5000005];
struct result
{
    
int x,y,d;
}
res[maxn];
int sind;
int q[500005],head,tail;
int len[maxn];
void cas_init()
{
    s[
0].init();
    sind
=1;
}

void ins(char srt[],int k)
{
    
int len=strlen(str);
    
int i,j,ind;
    ind
=0;
    
for(i=0;i<len;i++)
    
{
        j
=str[i]-'A';
        
if(s[ind].next[j]==-1)
        
{
            s[sind].init();
            s[ind].next[j]
=sind++;
        }

        ind
=s[ind].next[j];
    }

    s[ind].count
=k;
}

void make_fail()
{
    head
=0;tail=0;
    
int i,ind,ind_f;
    
for(i=0;i<26;i++)
    
{
        
if(s[0].next[i]!=-1)
        
{
            q[
++tail]=s[0].next[i];
        }

    }

    
while(head<tail)
    
{
        ind
=q[++head];
        
for(i=0;i<26;i++)
        
{
            
if(s[ind].next[i]!=-1)
            
{
                q[
++tail]=s[ind].next[i];
                ind_f
=s[ind].fail;
                
while(ind_f>0&&s[ind_f].next[i]==-1)
                ind_f
=s[ind_f].fail;
                
if(s[ind_f].next[i]!=-1)
                ind_f
=s[ind_f].next[i];
                s[s[ind].next[i]].fail
=ind_f;
            }

        }

    }

}

bool check(int x,int y)
{
    
return (x>=0&&x<n&&y>=0&&y<m);
}

void fd(int x1,int y1,int d)
{
    
int di,i,ind,p,x,y;
    ind
=0;x=x1;y=y1;
    
for(;check(x,y);x+=dx[d][0],y+=dx[d][1])
    
{
        i
=s1[x][y]-'A';
        
while(ind>0&&s[ind].next[i]==-1)
        ind 
=s[ind].fail;
        
if(s[ind].next[i]!=-1)
        
{
            ind
=s[ind].next[i];
            p
=ind;
            
//printf("%d\n",ind);
            while(p>0&&s[p].count!=-1)
            
{
                
int tmp=s[p].count;
                res[tmp].x
=x-(len[tmp]-1)*dx[d][0];
                res[tmp].y
=y-(len[tmp]-1)*dx[d][1];
                res[tmp].d
=d;
                
//cout<<s[p].count<<" "<<x1<<" "<<y1<<" "d<<endl;
                s[p].count=-1;
                p
=s[p].fail;
            }

        }

    }

}

int main()
{
    scanf(
"%d%d%d",&n,&m,&w);
    
for(int i=0;i<n;i++) scanf("%s",s1[i]);
    cas_init();
    
for(int i=1;i<=w;i++)
    
{
        scanf(
"%s",str);
        len[i]
=strlen(str);
        ins(str,i);
    }

    make_fail();
    
for(int i=0;i<m;i++)
    
{
        fd(
0,i,3);fd(0,i,4);fd(0,i,5);
        fd(n
-1,i,7);fd(n-1,i,0);fd(n-1,i,1);
    }

    
for(int i=0;i<n;i++)
    
{
        fd(i,
0,1);fd(i,0,2);fd(i,0,3);
        fd(i,m
-1,5);fd(i,m-1,6);fd(i,m-1,7);
    }

    
for(int i=1;i<=w;i++)
    printf(
"%d %d %c\n",res[i].x,res[i].y,res[i].d+'A');
    
return 0;
}



這個(gè)題說(shuō)的還是比較模糊的了,沒(méi)有說(shuō)明多個(gè)匹配的情況怎么辦,
但是它special judge了,應(yīng)該是輸出任意一中情況即可

posted on 2012-07-18 00:06 jh818012 閱讀(243) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


<2025年11月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

留言簿

文章檔案(85)

搜索

最新評(píng)論

  • 1.?re: poj1426
  • 我嚓,,輝哥,,居然搜到你的題解了
  • --season
  • 2.?re: poj3083
  • @王私江
    (8+i)&3 相當(dāng)于是 取余3的意思 因?yàn)?3 的 二進(jìn)制是 000011 和(8+i)
  • --游客
  • 3.?re: poj3414[未登錄](méi)
  • @王私江
    0ms
  • --jh818012
  • 4.?re: poj3414
  • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
  • --王私江
  • 5.?re: poj1426
  • 評(píng)論內(nèi)容較長(zhǎng),點(diǎn)擊標(biāo)題查看
  • --王私江
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产精品久久婷婷六月丁香| 91久久久久久久久| 久热精品视频在线| 亚洲第一页在线| 美女诱惑一区| 99热这里只有成人精品国产| 新67194成人永久网站| 国内精品免费在线观看| 老司机午夜免费精品视频| 亚洲风情亚aⅴ在线发布| 永久91嫩草亚洲精品人人| 欧美激情第3页| 亚洲美女av网站| 久久精品国产精品亚洲综合| 亚洲精品影院| 欧美视频在线观看| 噜噜噜久久亚洲精品国产品小说| 一本久久知道综合久久| 欧美 日韩 国产一区二区在线视频 | 亚洲日本无吗高清不卡| 亚洲永久视频| 亚洲高清在线观看一区| 国产精品入口麻豆原神| 免费亚洲一区| 久久av老司机精品网站导航| 日韩视频久久| 欧美电影美腿模特1979在线看| 亚洲影视在线| 亚洲美女视频在线免费观看| 日韩视频在线免费观看| 欧美日韩色一区| 久久久综合网| 欧美一区二区免费| 日韩一区二区福利| 欧美成人蜜桃| 久久久天天操| 亚洲欧美中文在线视频| 99精品国产在热久久婷婷| 在线观看视频一区| 国产啪精品视频| 欧美午夜无遮挡| 欧美二区不卡| 久久久国产精品一区二区中文| 国产精品99久久不卡二区| 亚洲国产专区校园欧美| 欧美freesex交免费视频| 午夜在线观看免费一区| 亚洲视频一二三| 一个人看的www久久| 在线观看三级视频欧美| 久久欧美中文字幕| 亚洲欧美在线x视频| 亚洲天堂网在线观看| 日韩一级黄色av| 亚洲欧洲精品天堂一级| 亚洲高清视频中文字幕| 欧美jizzhd精品欧美喷水| 久久亚洲私人国产精品va媚药| 午夜一级在线看亚洲| 午夜视频一区在线观看| 午夜老司机精品| 亚洲无亚洲人成网站77777| 久久久久久久999精品视频| 久久国产精品黑丝| 欧美在线综合| 欧美/亚洲一区| 美脚丝袜一区二区三区在线观看| 久久久久国色av免费看影院| 久久不射中文字幕| 欧美亚洲综合网| 欧美在线观看天堂一区二区三区| 香蕉久久夜色| 久久麻豆一区二区| 免费观看成人www动漫视频| 欧美成人中文字幕| 欧美电影资源| 欧美视频在线观看| 国产精品视频精品| 国产一区二区三区丝袜| 黄色成人av网站| 亚洲人成小说网站色在线| 在线精品亚洲| 日韩亚洲国产欧美| 亚洲欧美在线高清| 久久久水蜜桃av免费网站| 免费日韩av电影| 亚洲人成艺术| 亚洲午夜高清视频| 久久激情视频| 欧美国产日韩二区| 国产精品国产三级国产普通话三级 | 午夜精品美女自拍福到在线| 亚洲天堂成人在线观看| 西西人体一区二区| 毛片一区二区三区| 亚洲美女啪啪| 欧美一区二区久久久| 免费影视亚洲| 国产精品美女一区二区| 激情视频一区二区| 亚洲老司机av| 久久精品欧美日韩| 亚洲高清不卡| 亚洲在线成人| 欧美大秀在线观看| 欧美午夜精品久久久久久浪潮| 国产亚洲精品综合一区91| 在线观看一区二区精品视频| 99精品久久免费看蜜臀剧情介绍| 亚洲在线视频观看| 女生裸体视频一区二区三区| 一区二区三区精品久久久| 久久精品视频免费| 欧美日韩麻豆| 黑人一区二区三区四区五区| 一区二区三区高清| 蜜臀久久99精品久久久久久9| 99re6热在线精品视频播放速度| 亚洲免费影院| 欧美日韩精品在线播放| 国产一区二区按摩在线观看| 一区二区三区高清不卡| 欧美高清视频在线| 欧美一区久久| 亚洲第一毛片| 欧美一区二区三区播放老司机| 久久一区精品| 亚洲视频一区在线观看| 男同欧美伦乱| 狠狠久久亚洲欧美专区| 亚洲网站在线观看| 亚洲国产片色| 久久久噜噜噜| 国产欧美视频一区二区| 国产精品99久久99久久久二8| 免费毛片一区二区三区久久久| 亚洲欧美日韩在线观看a三区| 欧美日韩精品久久| 亚洲精品视频在线观看网站| 久久综合久久综合久久| 亚洲免费在线| 国产精品久久久一区二区三区| 91久久综合亚洲鲁鲁五月天| 久久亚洲一区二区三区四区| 亚洲先锋成人| 欧美成人午夜77777| 美女任你摸久久| 欧美少妇一区二区| 亚洲欧洲日产国码二区| 久久精品盗摄| 亚洲你懂的在线视频| 欧美午夜激情小视频| 一区二区不卡在线视频 午夜欧美不卡在 | 久久综合网色—综合色88| 国产精品欧美精品| 亚洲淫片在线视频| 亚洲最新合集| 国产精品黄色在线观看| 亚洲一区精品视频| 99ri日韩精品视频| 欧美日韩一区二区在线播放| 亚洲乱码一区二区| 亚洲人成77777在线观看网| 久久亚洲一区| 在线观看欧美日韩国产| 免费日韩一区二区| 久久国产加勒比精品无码| 国产一区清纯| 开心色5月久久精品| 久久久无码精品亚洲日韩按摩| 伊人久久大香线蕉综合热线| 久久综合激情| 欧美大片在线看| 国产精品99久久久久久久vr | 亚洲第一色在线| 欧美成人综合| 欧美理论电影在线观看| 一本色道久久| 99国产精品视频免费观看| 国产精品va| 久久aⅴ国产紧身牛仔裤| 午夜精品999| 影音先锋亚洲视频| 亚洲激情成人网| 国产一区二区视频在线观看| 久久久久久香蕉网| 久久影院午夜论| 日韩亚洲成人av在线| 亚洲社区在线观看| 国产亚洲午夜高清国产拍精品| 麻豆av一区二区三区久久| 欧美成人精品一区二区| 亚洲专区免费| 久久国产精品久久国产精品| 在线成人激情| 日韩一级欧洲| 国产一区二区三区观看| 欧美成人免费观看| 欧美午夜片欧美片在线观看| 久久精品国产99|