弦图判定

  代码

 #include<cstdio>
#include<queue>
#define mp make_pair
#define fi first
#define sc second
using namespace std;
const int N = ;
int n,m,a,b,i,j;
int dp,p[N],pre[N],tt[N],o,vis[N],sum[N],id[N],ID[N];
priority_queue<pair<int,int> > Q;
void link(int x,int y)
{
dp++;pre[dp]=p[x];p[x]=dp;tt[dp]=y;
}
int main()
{
scanf("%d%d",&n,&m);
for (i=;i<=m;i++)
{
scanf("%d%d",&a,&b);
link(a,b);
link(b,a);
}
for (i=;i<=n;i++)
Q.push(mp(,i));
o=n;
while (!Q.empty())
{
int x=Q.top().fi;
int y=Q.top().sc;
Q.pop();
if (vis[y]) continue;
if (x<sum[y]) continue;
ID[y]=o;
id[o--]=y;
vis[y]=;
i=p[y];
while (i)
{
if (!vis[tt[i]])
{
sum[tt[i]]++;
Q.push(mp(sum[tt[i]],tt[i]));
}
i=pre[i];
}
}
for (i=;i<=n;i++) vis[i]=; for (j=;j<=n;j++)
{
int x=id[j],cnt1=,cnt2=,mi=0x37373737,y=;
i=p[x];
while (i)
{
if (ID[tt[i]]>j)
{
if (ID[tt[i]]<mi) mi=ID[tt[i]],y=tt[i];
vis[tt[i]]=;cnt1++;
}
i=pre[i];
} if (y)
{
i=p[y];
while (i)
{
if (vis[tt[i]]) cnt2++;
i=pre[i];
}
}
if ((cnt1!=cnt2+)&&(y))
{
printf("Imperfect");
return ;
}
i=p[x];
while (i)
{
vis[tt[i]]=;
i=pre[i];
}
}
printf("Perfect");
}

Zju1015 Fishing Net的更多相关文章

  1. bzoj 1242: Zju1015 Fishing Net 弦图判定

    1242: Zju1015 Fishing Net弦图判定 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 214  Solved: 81[Submit ...

  2. [bzoj1242] Zju1015 Fishing Net弦图判定

    弦图判定..MCS算法. 先选一个点,然后每次拿 相邻已选点最多 的未选点. 选完之后判断一下是否是完美消除序列. #include<cstdio> #include<iostrea ...

  3. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  4. ZOJ 1015 Fishing Net(弦图判定)

    In a highly modernized fishing village, inhabitants there make a living on fishery. Their major tool ...

  5. Poj/OpenJudge 1042 Gone Fishing

    1.链接地址: http://bailian.openjudge.cn/practice/1042/ http://poj.org/problem?id=1042 2.题目: Gone Fishing ...

  6. POJ 1042 Gone Fishing (贪心)(刘汝佳黑书)

    Gone Fishing Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 30281   Accepted: 9124 Des ...

  7. uva757 - Gone Fishing(馋)

    题目:uva757 - Gone Fishing(贪心) 题目大意:有N个湖泊仅仅有一条通路将这些湖泊相连. 每一个湖泊都会给最開始5分钟间隔内能够调到的鱼(f).然后给每过5分钟降低的鱼的数量(d) ...

  8. ●BZOJ 1006 [HNOI2008]神奇的国度(弦图最小染色数)○ZOJ 1015 Fishing Net

    ●赘述题目 给出一张弦图,求其最小染色数. ●题解 网上的唯一“文献”:<弦图与区间图>(cdq),可以学习学习.(有的看不懂) 摘录几个解决改题所需的知识点: ●子图和诱导子图(一定要弄 ...

  9. Cocos2d-X开发教程-捕鱼达人 Cocos2-x development tutorial - fishing talent

    Cocos2d-X开发教程-捕鱼达人 Cocos2-x development tutorial - fishing talent 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱 ...

随机推荐

  1. Linux多线程实例练习 - pthread_create()

    Linux多线程实例练习 pthread_create():创建一个线程 int pthread_create(pthread_t *tidp, const pthread_attr_t *attr, ...

  2. iosiPhone屏幕尺寸、分辨率及适配

    iosiPhone屏幕尺寸.分辨率及适配     1.iPhone尺寸规格 设备 iPhone 宽 Width 高 Height 对角线 Diagonal 逻辑分辨率(point) Scale Fac ...

  3. [CareerCup] 16.3 Dining Philosophers 哲学家聚餐问题

    16.3 In the famous dining philosophers problem, a bunch of philosophers are sitting around a circula ...

  4. Js特效--模仿滚动条(兼容IE8+,FF,Google)

    <html> <head> <style> *{margin:0px;padding:0px;} #box{width:200px;height:500px;pos ...

  5. 百度ueditor代码高亮显示

    <script type="text/javascript" charset="utf-8" src="ueditor1_4_3-utf8-ph ...

  6. iPhone6分辨率与适配

    iPhone6分辨率与适配 分辨率和像素 经新xcode6模拟器验证(分辨率为pt,像素为真实pixel): iPhone5分辨率320x568,像素640x1136,@2x iPhone6分辨率37 ...

  7. mysqld诡异crash

    突然收到告警短信,提示有一组服务器MHA已经切换,登录服务器后查看错误日志如下(其中相关insert语句已经处理): mysql版本:5.5.24 :: InnoDB: Assertion failu ...

  8. 网页FLASH幻灯片播放带链接源代码 pixviewer.swf使用(转)

        <script type="text/javascript"> <!-- var focus_width=360 var focus_height=270 ...

  9. window对象中的常见方法

    <body><!-- window对象中的常见方法--><script type="text/javascript"> var timeid; ...

  10. BOM&Navigator对象

    <!-- BOM:Brower Object Model 浏览器对象模型 这个模型方便操作浏览器 浏览器对应的对象就是windows对象,这个可以通过查阅DHTML API获得 --> & ...