[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 ...
随机推荐
- poj2955 区间dp
//Accepted 200 KB 63 ms //区间dp //dp[i][j] 从i位到j位能得到的最大匹配数 //dp[i][j]=max(dp[i+1][j-1] (s[i-1]==s[j-1 ...
- web api post传一个参数时 值永远是null
这个问题纠结了我一个早上,不管用什么样的传参方法,走到控制器中,那个参数永远不变的等于null 在网上找了很多解决方案 上面这个是从网上截图的,第一:要将参数标记为[FromBody],变为简单参数 ...
- myEclipse下安装SVN插件
step1.首先下载svn插件, step2.将下载下来的插件解压缩任意目录,找到里面的features 和plugins两个文件夹, step3.在myEclipse的安装目录下找到dropins文 ...
- How to Avoid OOM in Android
1.use java reference(strong soft weak phantom) 2.use android:largeHeap="true" above or VMR ...
- Intellij导入外部的jar
File -> Project Structure (ctrl + shift + alt + s ) -> Module -> Dependencies -> Add... ...
- c#使用正则表达式替换html标签
/// <summary> /// 去除HTML标记(用正则彻底去除HTML\CSS\script代码 ) /// </summary> /// <param name= ...
- [转]iOS游戏如何防御外挂及IAP破解
http://www.j1f3.com/news/game/21371.html 今年3月初写过一篇<iO平台游戏安全小议>,到现今已有7个月了.在这段时间内,iOS平台上的安全问题也产生 ...
- PowerShell 语法结构
Get-Service -name P* [int]$a = 2 write-output $a [string]$b = "string" write-output $b #$c ...
- CentOS下安装keepalived 进行服务器热备
一.准备: 1.1 安装依赖软件 如果系统为基本文本安装,需要安装一下软件 yum -y install ipvsadm yum -y install kernel kernel-devel reb ...
- R编程感悟
虽然大学阶段曾经学过C++, matlab等编程,但是真的几乎完全还给了老师- 所以,我一直将R 作为自己真正学习的第一门语言.我从2012年初在来美国的第二个rotation中开始接触到了R.当时不 ...