[AMPPZ 2013]Bytehattan
先把题目链接贴在这里喵~
http://main.edu.pl/en/archive/amppz/2013/baj
话说真是一道让我严重怀疑我的智商的好题目,
话说此题第一感觉。嗯?似乎离线做做就可以了喵?
诶呦我艹,这个和强制在线一样的感觉是怎么一回事啊!
然后我苦思良久,终于在我他喵的苦思冥想之下,发现了——
此题果然非我所能破~
但是看了题解后顿时表示这么多年书白读了TAT
首先原图是平面图,且仅有删边操作
我们维护原图G的对偶图G'的一个子图G'',这个子图的连通性对应了G中各个域(各个方块)的连通性
一开始没有边被删去, V''=V' , E'=Ø ,说明各个域都不连通
然后每(在G中)删一条边,就在G''中加上对应的那条边
我们注意到现在只有加边的操作,可以用并查集维护所有域的连通性!
而且因为平面图的对偶图仍是平面图,平面图的子图仍是平面图

#include <cstdio>
const int size=; namespace IOspace
{
inline char getch()
{
register char ch;
do ch=getchar(); while (ch!='E' && ch!='N');
return ch;
}
inline int getint()
{
register int num=;
register char ch;
do ch=getchar(); while (ch<'' || ch>'');
do num=num*+ch-'', ch=getchar(); while (ch>='' && ch<='');
return num;
}
inline void putint(bool num)
{
if (num==) printf("TAK\n");
else printf("NIE\n");
}
} int n, k;
inline void swap(int & x, int & y) {int t=x; x=y; y=t;} struct node
{
int x, y;
inline node() {}
inline node(int _x, int _y):x(_x), y(_y) {}
};
inline int f(int x, int y) {if (x== || x==n || y== || y==n) return ; return (x-)*(n-)+y;}
inline node getedge(); int r[size];
inline void prepare() {for (int i=;i<n*n;i++) r[i]=i;}
int find(int x) {return r[x]==x?x:r[x]=find(r[x]);}
inline void merge(int x, int y) {x=find(x); y=find(y); r[x]=y;} int main()
{
bool ans;
node T, N; n=IOspace::getint(), k=IOspace::getint();
prepare();
ans=;
for (int i=;i<=k;i++)
{
T=getedge(); N=getedge();
if (ans) T=N;
ans=find(T.x)==find(T.y);
IOspace::putint(ans);
merge(T.x, T.y);
} return ;
} inline node getedge()
{
int x=IOspace::getint(), y=IOspace::getint();
char c=IOspace::getch();
if (c=='N') return node(f(x-, y), f(x, y));
if (c=='E') return node(f(x, y-), f(x, y));
}
本傻装B系列
[AMPPZ 2013]Bytehattan的更多相关文章
- 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...
- SharePoint 2013: A feature with ID has already been installed in this farm
使用Visual Studio 2013创建一个可视web 部件,当右击项目选择"部署"时报错: "Error occurred in deployment step ' ...
- Visual Studio 2013 添加一般应用程序(.ashx)文件到SharePoint项目
默认,在用vs2013开发SharePoint项目时,vs没有提供一般应用程序(.ashx)的项目模板,本文解决此问题. 以管理员身份启动vs2013,创建一个"SharePoint 201 ...
- SharePoint 2013 create workflow by SharePoint Designer 2013
这篇文章主要基于上一篇http://www.cnblogs.com/qindy/p/6242714.html的基础上,create a sample workflow by SharePoint De ...
- Install and Configure SharePoint 2013 Workflow
这篇文章主要briefly introduce the Install and configure SharePoint 2013 Workflow. Microsoft 推出了新的Workflow ...
- SharePoint 2013 configure and publish infopth
This article will simply descript how to configure and publish a InfoPath step by step. Note: To con ...
- TFS 2013 培训视频
最近给某企业培训了完整的 TFS 2013 系列课程,一共四天. 下面是该课程的内容安排: 项目管理 建立项目 成员的维护 Backlog 定义 任务拆分 迭代 ...
- Visual Studio 2013 Ultimate因为CodeLens功能导致Microsoft.Alm.Shared.Remoting.RemoteContainer.dll高CPU占用率的折中解决方案
1.为什么Microsoft.Alm.Shared.Remoting.RemoteContainer.dll的CPU占用率以及内存使用率会那么高? 在Visual Studio 2013 Ultima ...
- 沙盒解决方案解决SharePoint 2013 以其他身份登陆的问题
众所周知,SharePoint 2013没有像SharePoint 2010那样有一个叫"以其他身份登录"的菜单项. 当然解决方案也很多,比如你可以直接修改Welcome.ascx ...
随机推荐
- android中正确导入第三方jar包
android中正确导入第三方jar包 andriod中如果引入jar包的方式不对就会出现一些奇怪的错误. 工作的时候恰好有一个jar包需要调用,结果用了很长时间才解决出现的bug. 刚开始是这样引用 ...
- Windows Azure上搭建SSTP VPN
一.服务器设置 首先,从0开始,你需要创建一个新的VM.我选择Windows Server 2012 R2,所有步骤和创建普通VM都一样,但最后在防火墙设置里一定要打开TCP 443端口: 创建完成后 ...
- jQuery 中 children() 与 find() 用法的区别
1.children() 与 find() 用法的区别 通过children获取的是该元素的下级元素,而通过find获取的是该元素的下级所有元素.
- leetcode 229 Majority Element II
这题用到的基本算法是Boyer–Moore majority vote algorithm wiki里有示例代码 1 import java.util.*; 2 public class Majori ...
- GSM Hacking:使用BladeRF、树莓派、YatesBTS搭建便携式GSM基站
每次看到黑客在网上发布的那些GSM技术相关文章我都十分惊讶.然而在没有Software Defined Radios (SDRs)之前,玩GSM并不便宜,除此之外想要好好玩你得下大功夫. 拓展阅读 G ...
- 测试题1 IOS面试基础题
免责声明:答案来自本人,错误之处敬请谅解 1.用变量a写出以下定义 a.一个整型数 int a=5; b.一个指向整型数的指针 int *a; c.一个指向指针的指针,它指向的指针是指向一个整 ...
- Net use命令
以指定账户密码建立网络磁盘 net use s: \\ip\ipc$ "密码" /user:“用户名”
- 总结PowerShell的常用命令
命令1: #连接Azure订阅账户 Add-AzureAccount #获取所有在连接着的Azure订阅 Get-AzureAcount Get-AzureSubscription #设置当前的Azu ...
- magento中某个商店实现部分样式
在magento的某个website中,已经有一个storeview A,现在要求在这个website下再创建一个新的storeview B,现在要求对于storeview B只有主页和分类页应用新的 ...
- magento如何获取某一产品的订单量代码
<?php $sku = nl2br($_product->getSku()); $_productCollection = Mage::getResourceModel('reports ...