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 ...
随机推荐
- hdu_1003_Max Sum
Max Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- 用QT 还是MFC ? (转)
我曾经使用过QT和MFC来开发过软件,我想和大家分享我使用他们时所体会的不同之处. 我并非一个职业作家,这篇文章可能看起来不如专业的杂志和网站上的那么条理清晰.但是,我在这里是用我自己的语言来表达我自 ...
- demo_05HTML5+CSS3绘制小鸟
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- linux下VI编辑器的使用
一.VI编辑器简述 VI 编辑器是Linux和Unix上最基本的文本编辑器,工作在字符模式下.由于不需要图形界面,使它成了效率很高的文本编辑器.尽管在Linux上也有很多图形界面的编辑器可 ...
- Collection View 自定义布局(custom flow layout)
Collection view自定义布局 一般我们自定义布局都会新建一个类,继承自UICollectionViewFlowLayout,然后重写几个方法: prepareLayout():当准备开始布 ...
- 消息队列msmq
http://q.cnblogs.com/q/26895/ 远程队列必须现在运程服务器上创建. 在 Windows Server 2008 上安装 IIS 服务和 MSMQ 功能后,系统会在 IIS ...
- HJA的异或值
HJA的异或值 查看 提交 统计 提问 总时间限制: 20000ms 内存限制: 512000kB 描述 形态形成场(Morphogenetic Field)假说是Rupert Sheldrake ...
- ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architecture i386
就是选择的运行版本太低了,点击项目,project,把iOS DeployMent Target改为比较高的版本就行
- LA 3882
动态规划: 白书上的题,看了好久看不懂刘汝佳的解法: 在网上无意中看到了大神的思路,比较好理解,膜拜! 他的思路是这样的: 设d[i]是n个数按顺时针方向分别从0开始编号,第一次删除0,以后每k个数删 ...
- CAVLC
在H.264标准中,CAVLC(Context-based Adaptive Variable Length Coding)被用于亮度和色度残差数据编码.在标准的码流结构中,CAVLC编码方式描述为c ...