zoukankan      html  css  js  c++  java
  • hdu1181暴搜

    数据量很少,暴搜就可以过了

    /*
     * hdu1181/win.cpp
     * Created on: 2012-7-30
     * Author    : ben
     */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    const int MAXN = 26;
    bool mymap[MAXN][MAXN], visited[MAXN];
    
    bool dfs(int s, int e) {
        if(mymap[s][e]) {
            return true;
        }
        for(int i = 0; i < MAXN; i++) {
            if(i != s && mymap[s][i] && !visited[i]) {
                visited[i] = true;
                if(dfs(i, e)) {
                    return true;
                }
            }
        }
        return false;
    }
    
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("data.in", "r", stdin);
    #endif
        char str[200];
        int a, b;
        memset(mymap, false, sizeof(mymap));
        while(scanf("%s", str) != EOF) {
            if(strcmp(str, "0") == 0) {
                memset(visited, false, sizeof(visited));
                visited[1] = true;
                if(dfs(1, 12)) {
                    puts("Yes.");
                }else {
                    puts("No.");
                }
                memset(mymap, false, sizeof(mymap));
            }else {
                a = str[0] - 'a';
                b = strlen(str);
                b = str[b - 1] - 'a';
                mymap[a][b] = true;
            }
        }
        return 0;
    }
  • 相关阅读:
    Python startswith()函数 与 endswith函数
    Oracle spool 小结
    表空间(TableSpace)
    Python logger模块
    Mysql rpm安装
    Python json与pickle
    Python 生成器总结
    Python 装饰器的总结
    eclipse 乱码问题总结
    Eclipse 中出现红色下划波浪线与红色感叹号
  • 原文地址:https://www.cnblogs.com/moonbay/p/2615439.html
Copyright © 2011-2022 走看看