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 ...
随机推荐
- Ubuntu1404+Django1.9+Apache2.4部署配置2配置文件设置
转载注明出处,个人博客:http://www.cnblogs.com/wdfwolf3/ Django首要的部署平台是WSGI,它是Python Web服务器和应用的标准.使用Apache和mod_w ...
- (转)Android 从底层实现让应用杀不死【失效Closed】(1)
转自:http://klob.diandi.life/?p=21#symple-tab-%e8%b0%83%e6%9f%a5%e5%af%b9%e8%b1%a1 情景还原: 我的应用调用了Notifi ...
- thinkphp中表有前缀名的时候申明模板的方法
$Model=new \Home\Model\Stu_activityModel; $Model=D('Stu_activity');//错误的声明不了
- 「译」如何正确学习JavaScript
原文:How to Learn JavaScript Properly 目录 不要这样学习JavaScript 本课程资源 1-2周(简介,数据类型,表达式和操作符) 3~4周(对象,数组,函数,DO ...
- mysql update不能直接使用select的结果
在sql server中,我们可是使用以下update语句对表进行更新:update a set a.xx= (select yy from b) ;但是在mysql中,不能直接使用set selec ...
- 【python之旅】python的面向对象
一.面向过程 VS 面向对象 1.编程范式 编程是程序员用特定的语法+数据结构+算法组成的代码来告诉计算机如何执行任务的过程,一个程序是程序员为了得到一个任务结果而编写的一组指令的集合,实现一个任务的 ...
- 解决delphi使用sqlite时中文最后一个字是乱码的问题
给部门同事写了个自动生成测试用例执行情况图表的工具,使用的sqlite3,遇到中文分别使用UTF8Encode和UTF8Decode进行处理,可还是出现了某些字段从数据库中读出时,最后一个汉字是乱码的 ...
- 秒懂sql intersect
首先我们介绍一下intersect这个单词,我们把inter 和sect分开查询,进行理解. inter :中间的 (internet,net是网,internet 表示网络内部之间的交流).而s ...
- BZOI 1507 [NOI2003] Editor
Background After trying to solve problem EDIT1(Editor) and being ****ed by Brainf**k, Blue Mary deci ...
- Contest20140705 testB DP
testB 输入文件: testB.in 输出文件testB.out 时限2000ms 问题描述: 方师傅有两个由数字组成的串 a1,a2,⋯,an 和 b1,b2,⋯,bm.有一天,方师傅感到十分无 ...