[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 ...
随机推荐
- swing LayoutManager 和多态
interface LayoutManager{ void show();}class FlowLayout implements LayoutManager{ public void show(){ ...
- 解决uploadify多图片上传部分图片丢失,且不提示任何错误的问题
这两天用到uploadify的flash版本进行批量图片上传并生成缩略图的功能,之前用uploadify用的好好的,这次突然出现了一个奇怪的问题. 问题描述如下:当我选择单个图片上传的时候,图片上传都 ...
- Listview之优化BaseAdapter中的getView中的contentView
BaseAdapter中getView中改动的地方: @Override public View getView(int position, View contentView, ViewGroup a ...
- PHP面向对象的继承
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 云计算平台简介(App Engine)
云计算平台简介(App Engine) 1 简介 App Engine: 应用程序引擎,是托管网络应用程序的云计算平台. 1.1 什么是云 云计算通常简称为“云”,是一种通过 Inter ...
- 解决mac eclipse 异常退出后无法打开处于loading状态
<workspace>\.metadata\.plugins\org.eclipse.core.resources目录,删除文件 .snap
- ubuntu 输入时弹出剪切板候选项
fcitx很坑的把这个功能的快捷键设置成了ctrl + ;结果我在用vim的时候怎么也 没法输入command 不知道是哪次更新引入的,简直是坑人! 我找了半天系统设置都没找到这个快捷键是在哪设置的. ...
- android中KSOAP2中的anytype{}问题
如果web返回为空,即空字符串的时候,KSOAP2会返回一个anytype{}这样的一个串回来,要比对下是不是这个串,如果是就返回null,从而避免查不到数据时没有相应处理. if (jsonStr. ...
- poll函数和串口设置
2015.1.24 今天星期六,多云,早晨8:17起床的,今天是来南京起床最迟的一天,因为昨晚睡得有点迟,今天又不用上课,整个人有点放松.收拾好来到教室,教室门没有开,胡明也到了,其他人还在宿舍睡觉, ...
- 简单的多线程(活用OD解决运行时错误)
代码源自<VC++深入详解>第15章 “多线程”,位于第563页 - 566 页. 程序的目的是展示多线程运行的效果: #include <windows.h> #includ ...