就是简单的用strstr函数对字符串进行处理。

另解:暴力(就是用strstr函数对字符串进行处理)另解:暴力(普通的字符串处理 。关键是strstr函数):
#include<stdio.h>
#include<string.h> struct Bing
{
char name[210];
int num;
}bing[510]; struct Web
{
char name[10010];
int num;
bool ok;
int a[4];
}web[1010]; int tot = 0; int main()
{
int n, m;
while(scanf("%d",&n) != EOF)
{
for (int i=0; i<1010; ++i)
{
memset(web[i].name, 0, sizeof(web[i].name));
web[i].ok = false;
memset(web[i].a, -1, sizeof(web[i].a));
web[i].num = 0;
}
tot = 0;
for (int i=0; i<n; ++i)
{
scanf("%s", bing[i].name);
bing[i].num = i+1;
}
scanf("%d", &m);
for (int i=0; i<m; ++i)
{
scanf("%s", web[i].name);
web[i].num = i + 1;
int cnt = 0;
for (int j=0; j<n; ++j)
{
if (strstr(web[i].name, bing[j].name))
{
web[i].ok = true;
web[i].a[cnt++] = j;
if (cnt == 3)
break;
}
}
} for (int i=0; i<m; ++i)
{
if (web[i].ok)
{
tot++;
printf("web %d:", web[i].num);
for (int j=0; j<3; ++j)
{
if (web[i].a[j] != -1)
{
printf(" %d", web[i].a[j] + 1);
}
}
printf("\n");
}
}
printf("total: %d\n", tot);
}
return 0;
}

POJ 2896 另解暴力的更多相关文章

  1. POJ 2896 AC自动机 or 暴力

    DESCRIPTION :大意是说.给你n个代表病毒的字符串.m个表示网站的字符串.让你计算有多少个网站被病毒感染了.被那些病毒感染了. 刚开始就想暴力.然而,忽略了条件:每个网站最多有三个病毒.于是 ...

  2. poj 3714 Raid【(暴力+剪枝) || (分治法+剪枝)】

    题目:  http://poj.org/problem?id=3714 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27048#prob ...

  3. poj 2021 Relative Relatives(暴力)

    题目链接:http://poj.org/problem?id=2021 思路分析:由于数据较小,采用O(N^2)的暴力算法,算出所有后代的年龄,再排序输出. 代码分析: #include <io ...

  4. POJ 3522 Slim Span 暴力枚举 + 并查集

    http://poj.org/problem?id=3522 一开始做这个题的时候,以为复杂度最多是O(m)左右,然后一直不会.最后居然用了一个近似O(m^2)的62ms过了. 一开始想到排序,然后扫 ...

  5. poj 2585 Window Pains 暴力枚举排列

    题意: 在4*4的格子中有9个窗体,窗体会覆盖它之下的窗体,问是否存在一个窗体放置的顺序使得最后的结果与输入同样. 分析: 在数据规模较小且不须要剪枝的情况下能够暴力(思路清晰代码简单),暴力一般分为 ...

  6. 【BZOJ-4059】Non-boring sequences 线段树 + 扫描线 (正解暴力)

    4059: [Cerc2012]Non-boring sequences Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 440  Solved: 16 ...

  7. POJ 1012 Joseph 推导,暴力,约瑟夫环,打表 难度:2

    http://poj.org/problem?id=1012 答案以954ms飘过,不过这道题可以轻松用打表过 思路:如果我们把每个人位于数组中的原始编号记为绝对编号,每次循环过后相对于绝对编号为0的 ...

  8. POJ - 3279(枚举+暴力)

    Fliptile Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14297   Accepted: 5257 Descrip ...

  9. POJ 1840 Eqs 解方程式, 水题 难度:0

    题目 http://poj.org/problem?id=1840 题意 给 与数组a[5],其中-50<=a[i]<=50,0<=i<5,求有多少组不同的x[5],使得a[0 ...

随机推荐

  1. 简单Shell案例

    使用shell命令进行左对齐或者右对齐 [root@bj-aws-yace-tbj mnt]# cat test.sh #! /bin/bash file=./test.txt echo -e &qu ...

  2. mysql-5.7.20-winx64.zip Zip版、解压版MySQL安装

    1.  zip下载地址: https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-winx64.zip 2.官方文档位置: http:// ...

  3. leetcode 最长有效括号

    给定一个只包含 '(' 和 ')' 的字符串,找出最长的包含有效括号的子串的长度. 示例 1: 输入: "(()" 输出: 2 解释: 最长有效括号子串为 "()&quo ...

  4. poj 1330 Nearest Common Ancestors lca 在线rmq

    Nearest Common Ancestors Description A rooted tree is a well-known data structure in computer scienc ...

  5. Python 实现协程

    协程的概念 协程,又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程.(其实并没有说明白~) 我觉得单说协程,比较抽象,如果对线程有一定了解的话,应该就比较 ...

  6. Ubuntu14.04 获取文件或者文件夹大小

    [root@bogon ~]# stat -c%s install.log

  7. [源][osg][osgBullet]osgBullet例子介绍

    1.BasicDemo 基本样例 一个小玩具飞机坠落,一个立方体盒子在转圈 2.centerofmass 质心 3.collision 碰撞检测 这里有一个大神自己改的例子: http://blog. ...

  8. Codeforces 545D - Queue

    545D - Queue 思路:忍耐时间短的排在前面,从小到大排序,贪心模拟,记录当前等待时间,如过等待时间大于当前的这个人得忍耐时间,那么就把这个人扔到最后面,不要管他了(哼╭(╯^╰)╮,谁叫你那 ...

  9. Lua面向对象 --- 多继承

    工程目录结构: ParentMother.lua: ParentMother = {} function ParentMother:MortherName() print("Morther ...

  10. Lua 中与字符串有关的函数学习

    string1 = "lua" print(string.upper(string1)) string2 = 'LGS' print(string.lower(string2)) ...