[AMPPZ 2013]Bytehattan
先把题目链接贴在这里喵~
http://main.edu.pl/en/archive/amppz/2013/baj
话说真是一道让我严重怀疑我的智商的好题目,
话说此题第一感觉。嗯?似乎离线做做就可以了喵?
诶呦我艹,这个和强制在线一样的感觉是怎么一回事啊!
然后我苦思良久,终于在我他喵的苦思冥想之下,发现了——
此题果然非我所能破~
但是看了题解后顿时表示这么多年书白读了TAT
首先原图是平面图,且仅有删边操作
我们维护原图G的对偶图G'的一个子图G'',这个子图的连通性对应了G中各个域(各个方块)的连通性
一开始没有边被删去, V''=V' , E'=Ø ,说明各个域都不连通
然后每(在G中)删一条边,就在G''中加上对应的那条边
我们注意到现在只有加边的操作,可以用并查集维护所有域的连通性!
而且因为平面图的对偶图仍是平面图,平面图的子图仍是平面图
![](https://images0.cnblogs.com/i/660496/201408/102000300376770.png)
#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 ...
随机推荐
- APP store 审核注意点
磨刀不误砍柴工.作为手机应用开发者,你需要向应用商店提交应用审核,迅速通过审核可以让你抢占先机.对苹果iOS应用开发者来说尤其如此.苹果应用商店的审核近乎吹毛求疵,下面这些清单可以让你知道苹果会在哪些 ...
- IIS 6.0 401 错误
1.错误号401.1 症状:HTTP 错误 401.1 - 未经授权:访问由于凭据无效被拒绝 分析: 由于用户匿名访问使用的账号(默认是IUSR_机器名)被禁用,或者没有权限访问计算机,将造成用户无 ...
- httplib、urllib、urllib2的区别
Python3.4互联网通讯协议支持 1,webbrowser方便的浏览器容器 2,cgi公共网关接口支持 3,cgitb管理cgi脚本 4,wsgiref WSGI实体和引用实现 5,urlli ...
- 【IOS基础知识】NSTimer定时器使用
1.声明 NSTimer *timer; 2.定义 timer = [NSTimerscheduledTimerWithTimeInterval:1.0ftarget:selfsele ...
- oracle 10gwindow7安装添加内容
F:\软件\database\stage\prereq\db\refhost.xml <!--Microsoft Windows 7 .Windows 8--> <OPERATING ...
- Ant、Maven、Gradle
android Gradle project http://www.ibm.com/developerworks/cn/opensource/os-cn-gradle/ http://www.voge ...
- hdu 2094
ps: 原本听说用set容器做是最好的...然而我并不懂..就用C语言做了...就是先输入赢得一组和输的一组,然后把重复的删掉,再比较赢得一组里没有出现在输的一组里的人数,如果是1就是YES,其他就是 ...
- Js的 "继承"
Js 和 Java , C等语言不是很一样 . 其他语言有 类和实例 但是Js就比较特殊 , 所以 类和实例 只能说是大多数面向对象编程的语言的基本概念 . Js比较特殊 , 它不去分类和实例的概念 ...
- Google protobuf
个人理解: 定义.proto文件就是指明消息里包含的成员和类型,protoc会compile成相应的java文件包含interface和implementation class,然后在构建messag ...
- 【LeetCode OJ】Best Time to Buy and Sell Stock II
Problem Link: http://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ We solve this prob ...