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;
    }
  • 相关阅读:
    JAVA 正则表达式 (超详细)
    <select>改造成<s:select>实现表单的回显功能
    打开新界面
    list删除操作 java.util.ConcurrentModificationException
    C# 增加 删除 更新 方法
    C# 网页内容获取
    excel 处理方法
    C# 读取excel
    sql 导入excel 遇到问题
    DataSet
  • 原文地址:https://www.cnblogs.com/moonbay/p/2615439.html
Copyright © 2011-2022 走看看