栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3690 Constellations

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3690 Constellations

#include <iostream>#include <algorithm>#include <cstring>#include <string>#include <cstdio>#include <cmath>#include <queue>#include <map>#include <set>#define MAXN 111111#define MAXM 555555#define INF 100000011#define lch(x) x<<1#define rch(x) x<<1|1#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define eps 1e-7using namespace std;long long h[1111][1111];int n, m, t, p, q;char mp[1111][1111], tmp[66];long long a[66];bool ok(){    for(int i = 0; i + p - 1 < n; i++)        for(int j = q - 1; j < m; j++)        { int flag = 1; for(int k = 0; k < p; k++)     if(h[i + k][j] != a[k])     {         flag = 0;         break;     } if(flag) return true;        }    return false;}int main(){    int cas = 0;    while(scanf("%d %d %d %d %d", &n, &m, &t, &p, &q) != EOF)    {        if(!n && !m && !t && !q && !p) break;        for(int i = 0; i < n; i++) scanf("%s", mp[i]);        memset(h, 0, sizeof(h));        for(int i = 0; i < n; i++) for(int j = 0; j < q; j++) {     if(mp[i][j] == '*') h[i][q - 1] |= (1LL << j); }        for(int i = 0; i < n; i++) for(int j = q; j < m; j++) {     if(mp[i][j - q] == '*') h[i][j] = h[i][j - 1] - 1LL;     else h[i][j] = h[i][j - 1];     h[i][j] >>= 1LL;     if(mp[i][j] == '*') h[i][j] |= (1LL << (q - 1)); }        int cnt = 0;        while(t--)        { for(int i = 0; i < p; i++) {     scanf("%s", tmp);     a[i] = 0;     for(int j = 0; j < q; j++)         if(tmp[j] == '*') a[i] |= (1LL << j); } if(ok()) cnt++;        }        printf("Case %d: %dn", ++cas, cnt);    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/374233.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号