填坑系列(p.172)

注意“可以旋转和翻转”

然后将每个字母看成点

不然边数就是n^2级的

 #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream> using namespace std; void setIO(const string& s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = ; c = getchar(), !isdigit(c); ) if(c == '-') f = ;
for(x = ; isdigit(c); c = getchar()) x = x * + c - '';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; read(x); return x;
} int ID(char a1, char a2) {
return (a1 - 'A') << | (a2 == '-');
} int G[][]; void AddEdge(char a1, char a2, char b1, char b2) {
if(a1 == '' || b1 == '') return;
int u = ID(a1, a2) ^ , v = ID(b1, b2);
G[u][v] = ;
} int vis[]; bool dfs(int u) {
vis[u] = -;
for(int v = ; v < ; v++) if(G[u][v]) {
if(vis[v] < ) return ;
if(!vis[v] && dfs(v)) return ;
}
vis[u] = ;
return ;
} bool find() {
memset(vis, , sizeof vis);
for(int u = ; u < ; u++) if(!vis[u]) {
if(dfs(u)) return ;
}
return ;
} int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif int n;
while(scanf("%d", &n) == && n) {
memset(G, , sizeof G);
char s[];
for(int i = ; i < n; i++) {
scanf("%s", s);
for(int i = ; i < ; i++) {
for(int j = ; j < ; j++) if(i ^ j) {
AddEdge(s[i << ], s[i << | ], s[j << ] , s[j << | ]);
}
}
}
if(find()) puts("unbounded");
else puts("bounded");
} return ;
}

UVa1572 UVaLive6393 Self-Assembly的更多相关文章

  1. 为C# as 类型转换及Assembly.LoadFrom埋坑!

    背景: 不久前,我发布了一个调试工具:发布:.NET开发人员必备的可视化调试工具(你值的拥有) 效果是这样的: 之后,有小部分用户反映,工具用不了(没反应或有异常)~~~ 然后,建议小部分用户换个电脑 ...

  2. ASP.NET Core: You must add a reference to assembly mscorlib, version=4.0.0.0

    ASP.NET Core 引用外部程序包的时候,有时会出现下面的错误: The type 'Object' is defined in an assembly that is not referenc ...

  3. An error occurred during the installation of assembly 'Microsoft.VC90.CRT……的问题

    有一段时间没有用到AnkhSvn了,今天工作需要安装了一下.结果安装到一半就无法继续了,提示An error occurred during the installation of assembly ...

  4. Beennan的内嵌汇编指导(译)Brennan's Guide to Inline Assembly

    注:写在前面,这是一篇翻译文章,本人的英文水平很有限,但内嵌汇编是学习操作系统不可少的知识,本人也常去查看这方面的内容,本文是在做mit的jos实验中的一篇关于内嵌汇编的介绍.关于常用的内嵌汇编(AT ...

  5. MAC上安装 HLA(High Level Assembly)

    1.安装HLA 最新版的hla汇编器可在这里下载,支持MacOs,Linux,Windows平台 2.安装步骤 将下载好的hla程序包放在Mac根目录下 最重要的一步是设置好环境变量,打开Mac根目录 ...

  6. .NET 程序集Assembly使用

    概述 一直以来,我们都在用C#编写程序,编写程序的时候,我们用到继承.多态.接口以及泛型,我们也都明白子类可以继承抽象类,并能够重写父类的抽象方法,可是大家是否想过,如下几个问题: 1.凡树必有根和叶 ...

  7. configuration error-could not load file or assembly crystaldecisions.reportappserver.clientdoc

    IIS启动网站后报错: configuration error Could not load file or assembly 'crystaldecisions.reportappserver.cl ...

  8. Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its de

    页面加载时出现这个错误: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Cul ...

  9. How to make your assembly more secure from referencing by unauthorized bits

    Now the security has a trend to become more and more important in our daily work, hence I did some r ...

随机推荐

  1. 使用微信api接口开发的框架

    <?php/** * 微信公众平台API */class WeixinChat{ private $token; private $appid; private $appsecret; priv ...

  2. 自动化运维工具之ansible

    自动化运维工具之ansible   一,ansible简介 ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fab ...

  3. [Machine Learning] Probabilistic Graphical Models:二、Bayes Network Fundamentals(1、Semantics & Factorization)

    一.How to construct the dependency? 1.首字母即随机变量名称 2.I->G是更加复杂的模型,但Bayes里不考虑,因为Bayes只是无环图. 3.CPD = c ...

  4. 配置并学习微信JS-SDK(3)—菜单接口

    1.设置菜单 //2.批量显示菜单项接口 wx.showMenuItems({   menuList: [     'menuItem:profile', //查看公众号     'menuItem: ...

  5. odoo9 install

    odoo9 的安装需要 nodejs 的 lessc 命令. 需要先安装nodejs 后,使用nmp(nodejs的一个包管理工具) 安装lessc等功能. window 1:安装nodejs. 安装 ...

  6. Python快速排序

    快排,取一个key值,一般取第一个即可,将小于key的放到左边,大于key的放到右边,递归实现 import random def quicksort(data, low = 0, high = No ...

  7. Python 学习笔记(2) - 基本概念、运算符与表达式

    字符串 - 可以使用 3 种形式 - 单引号 :「'your string'」 - 双引号 :「"your string"」 - 三引号 :「'''your string''' 或 ...

  8. Xcode6插件开发

    工欲善其事必先利其器,Xcode是我们做iOS Dev必须掌握的一款开发工具. Xcode本身也是一门Cocoa程序,与其来说它是一个Cocoa程序,是不是意味着,我们可以去动态去让它做某件事,或者监 ...

  9. JDK下sun.net.www.protocol.http.HttpURLConnection类-----Http客户端实现类的实现分析

    HttpClient类是进行TCP连接的实现类, package sun.net.www.http; import java.io.*; import java.net.*; import java. ...

  10. Mac os 10.9下面配置JAVA_HOME

    刚入手的的MBP,就开始配置java环境,搜了一下网上的都是10.9以前的配置方法.jdk7在10.9的安装目录变化了. 首先到Oracle官网下载最新版本的java,直接默认安装 cd /etc s ...