[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 ...
随机推荐
- numpy中的broadcast
关于broadcast,官方文档描述如下: Each universal function takes array inputs and produces array outputs by perfo ...
- IP地址 子网掩码 默认网关 网络地址 广播地址
“IP地址”是“TCP/IP”(Transmite Control Protocol 传输控制协议/Internet Protocol网际协议)里其中的一种协议. Internet之所以能将广阔范围内 ...
- Python 字符串处理大全.
Python 字符串 字符串是Pyhton中常用的数据类型,我们可以使用引号来创建字符串 . 创建字符串很简单 , 就不说了 . Python 访问字符串中的值 鬼叔本着简洁 使用的设计目的 , 在设 ...
- iOS开发:bitcode介绍和使用cocoapods出现“target overrides the `OTHER_LDFLAGS`……”的解决方案
在开发中,不免需要引入第三方库,但是因为库的问题,会发生很多错误.如: 1.因为一些第三方库不包含bitcode就会报错: 一次使用xcode7.1时,发现编译失败,报错信息: umeng messa ...
- IOS 作业项目(4)步步完成 画图 程序(上)
先上流程图
- Supermarket_贪心
Description A supermarket has a set Prod of products on sale. It earns a profit px for each product ...
- Unity3D ShaderLab 模拟纹理运动
Unity3D ShaderLab 模拟纹理运动 这一篇,我们要说到着色器上的uv贴图的滚动效果,这样的场景可以用在河流,瀑布,熔岩等效果.算是创建纹理动画的基础技术之一. 所以 准备一个新的着色器文 ...
- C#判断字符串是否为数字
string i = Console.ReadLine(); int a=0; if (int.TryParse(i, out a) == false) / ...
- js 字符串转化成数字:(实例:用正则检测大于0的正数,最多保留4位小数)
来源:http://www.cnblogs.com/hwx0807/archive/2011/06/28/2092021.html 实例: function BindSubmitEvent() { / ...
- 《MORE EFFECTIVE C++》条款27 要求或者禁止对象分配在堆上
1. 要求对象分配在堆上 临时对象一般是存在于栈中的,或者是静态对象存在于常量存储区的.那么当创建一个这样的对象的时候,一般是需要隐式或显式地调用构造函数,在销毁的时候调用析构函数的.可以从这方面入手 ...