UVa1572 UVaLive6393 Self-Assembly
填坑系列(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的更多相关文章
- 为C# as 类型转换及Assembly.LoadFrom埋坑!
背景: 不久前,我发布了一个调试工具:发布:.NET开发人员必备的可视化调试工具(你值的拥有) 效果是这样的: 之后,有小部分用户反映,工具用不了(没反应或有异常)~~~ 然后,建议小部分用户换个电脑 ...
- 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 ...
- An error occurred during the installation of assembly 'Microsoft.VC90.CRT……的问题
有一段时间没有用到AnkhSvn了,今天工作需要安装了一下.结果安装到一半就无法继续了,提示An error occurred during the installation of assembly ...
- Beennan的内嵌汇编指导(译)Brennan's Guide to Inline Assembly
注:写在前面,这是一篇翻译文章,本人的英文水平很有限,但内嵌汇编是学习操作系统不可少的知识,本人也常去查看这方面的内容,本文是在做mit的jos实验中的一篇关于内嵌汇编的介绍.关于常用的内嵌汇编(AT ...
- MAC上安装 HLA(High Level Assembly)
1.安装HLA 最新版的hla汇编器可在这里下载,支持MacOs,Linux,Windows平台 2.安装步骤 将下载好的hla程序包放在Mac根目录下 最重要的一步是设置好环境变量,打开Mac根目录 ...
- .NET 程序集Assembly使用
概述 一直以来,我们都在用C#编写程序,编写程序的时候,我们用到继承.多态.接口以及泛型,我们也都明白子类可以继承抽象类,并能够重写父类的抽象方法,可是大家是否想过,如下几个问题: 1.凡树必有根和叶 ...
- configuration error-could not load file or assembly crystaldecisions.reportappserver.clientdoc
IIS启动网站后报错: configuration error Could not load file or assembly 'crystaldecisions.reportappserver.cl ...
- 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 ...
- 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 ...
随机推荐
- 嵌入式web server——Goahead移植要点
前言 在嵌入式设备中,在没有液晶显示的情况下,可以使用web来访问设备,查看设备的运行状态以及进行参数设置,类似于路由器设置.网上有很多关于各种web server的优劣的评论,在此不讨论,只是介绍其 ...
- jQuery慢慢啃之事件对象(十一)
1.event.currentTarget//在事件冒泡阶段中的当前DOM元素 $("p").click(function(event) { alert( event.curren ...
- Linux 中查看网口流量的利器 -- sar
Linux 中查看网口流量的利器 -- sar 有这么一个小工具,通过它能够查看各个网口的IP报文流量统计. 利用sar命令,加上-n DEV参数,即可统计出所有网卡上的流量,在显示的第五和第六列 ...
- 《cut命令》-linux命令五分钟系列之十九
本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...
- grub2 使用memdisk工具 启动任意iso
root@zhanghua-Inspiron-:/home/zhanghua# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda6 60G 12G 46G 21% / none ...
- js判断用户进入设备代码
var system ={ win : false, mac : false, xll : false }; //检测平台 var p = navigator.platform; system.win ...
- 2016021801 - Java内存区域学习笔记
根据<深入理解java虚拟机>学习归纳整理学习笔记 程序计数器 用途:当前线程的字节码文件的行号指示器.(当前机场负责控制飞机降落的空管员:当前线程表示当前机场, 所执行的字节码等同于被等 ...
- finalspeed服务器端和客户端安装
https://www.91yun.org/archives/2775 https://www.91yun.org/archives/615 1.首先安装服务器端:一键安装代码 wget -N --n ...
- Android Studio与Genymontion的安装
需要安装的软件: VirtualBox 5.1.4 Genymotion 2.7.2 Android Studio 2.1.2 安装步骤: 使用安装版安装Android Studio 1. 执 ...
- vim设置
折腾一下vim http://www.cnblogs.com/zhangsf/archive/2013/06/13/3134409.html