目测某年HNOI,(其实这个题是2011年的WF,hdu上找到的,HNOI2012那个中文题在bzoj和loj上都有,叫矿场搭建,题意几乎一样,数据比较弱,交这份代码也能A)。

先讲题解,然后说一些有(e)趣(xin)的事情。

首先肯定是个点双,先求一下点双。

然后我们分析一下。

当这个点双里没割点时(一个大号的孤立点双),那么我们要建两个特殊节点,因为一个塌了可以去另一个,对第1问贡献为2,第2问贡献贡献为C(n,2)=(n-1)*n/2。(n是点双大小哦)。

当这个点双有一个割点(一个叶子),那么我们在除割点以外的地方建特殊节点,因为割点塌了去自家的,自家的塌了走割点去隔壁的。对第1问贡献为1,第2问贡献为n-1。(n是点双大小哦)。

当这个点双有两个及以上割点时,别建,天塌下来有两个及以上隔壁顶着。无贡献。

多测,注意清空。

下面说一些题外话。

这个题码完以后去bzoj交那个中文题,WA了,交loj,70,一看,错的是那三个小点,大点都过了……后来发现T清零了……case一个1,若干0,赶紧改,一交A了,回bzoj,A了。

然后交自家oj,RE,一看,数组可能要2倍,开完一交,又RE,一直交,一直RE,我去,这数据也TQL,一想,可能挂在外网上,min和max都改手打,还是RE,到处窜座去问,没人能给出解答(因为我是倒着刷的),然后去找啾啾,他上hdu给我找了一手,找到了,交,TLE,3000,一个测试点?WF?这么那啥。静态调错,init里边数没清零……明白了,那两个A的是因为数据太小,我的数组开的太大,不清空边数都没炸……那WF的题5e4的大范围,不出5个就卡死了,赶紧改,交,WA了。

静态调错,ans2*=写的赋值,点双大小写的n(知道我上文为什么要强调了吗?我推的时候拿n推的,打的时候忘了),改,交,A了。

现在又明白一个问题,bz和loj上的那道题,只有一个点双就是一个大的点双,没有孤立的,所以上面的错误就是正确的。

所以,做完这个题就不要去做那个题了,没意思了。(试了试,ans2*=C(n,2)也能A,有点迷,难不成WF也默认了?)

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
int read(){
int sum=,f=;char x=getchar();
while(x<''||x>''){
if(x=='-') f=-;
x=getchar();
}while(x>=''&&x<=''){
sum=sum*+x-'';
x=getchar();
}return sum*f;
}
struct EDGE{
int ed,nex;
}edge[];
int first[],num;
int n,m,root;
int dfn[],low[],sta[];
int ord,top,vccnum,T;
vector<int>vcc[];
long long ans1=,ans2=;
bool cut[];
inline int max(int a,int b){
return a>b?a:b;
}
inline int min(int a,int b){
return a<b?a:b;
}
void init(){
memset(edge,,sizeof(edge));
memset(first,,sizeof(first));
memset(dfn,,sizeof(dfn));
memset(low,,sizeof(low));
memset(cut,,sizeof(cut));
for(int i=;i<=vccnum;i++) vcc[i].clear();
ord=top=num=vccnum=ans1=root=n=;
ans2=;
} void tarjan(int x){
dfn[x]=low[x]=++ord;
sta[++top]=x;
if(x==root&&first[x]==){
vcc[++vccnum].push_back(x);
return ;
}
int child=;
for(int i=first[x];i;i=edge[i].nex){
int y=edge[i].ed;
if(!dfn[y]){
tarjan(y);
low[x]=min(low[x],low[y]);
if(low[y]>=dfn[x]){
child++;
if((x==root&&child>=)||(x!=root&&child>)) cut[x]=;
vcc[++vccnum].push_back(x);
int p;
do{
p=sta[top--];
vcc[vccnum].push_back(p);
}while(p!=y);
}
}else low[x]=min(low[x],dfn[y]);
}
}
void add(int st,int ed){
edge[++num].ed=ed;
edge[num].nex=first[st];
first[st]=num;
}
int main(){
// freopen("c.in","r",stdin);
m=read();
while(m!=){
T++;
for(int i=,x,y;i<=m;i++){
x=read();y=read();
add(x,y);add(y,x);
n=max(n,x);n=max(n,y);
}
for(int i=;i<=n;i++)
if(!dfn[i]) root=i,tarjan(i);
for(int i=;i<=vccnum;i++){
int sum=;
for(int j=;j<vcc[i].size();j++)
if(cut[vcc[i][j]])
sum++;
if(!sum){
ans1+=;
ans2*=vcc[i].size()*(vcc[i].size()-)/;
}
else if(sum==){
ans1++;
ans2*=1ll*(vcc[i].size()-);
}
}
printf("Case %d: %lld %lld\n",T,ans1,ans2);
m=read();init();
}
}

带着浓重的戾气。

HDU3844Mining Your Own Business的更多相关文章

  1. 在 SharePoint Server 2016 本地环境中设置 OneDrive for Business

    建议补丁 建议在sharepoint2016打上KB3127940补丁,补丁下载地址 https://support.microsoft.com/zh-cn/kb/3127940 当然不打,也可以用O ...

  2. Java Business Process Management(业务流程管理) 初识环境搭建

    一.简介 (一)什么是jbpm JBPM,全称是Java Business Process Management(业务流程管理),它是覆盖了业务流程管理.工作流.服务协作等领域的一个开源的.灵活的.易 ...

  3. Tips for Planning Your Business Startup

    原文链接:http://domaintree.me/?p=1037 By Robert Thibodeau –  Starting a business can be a very daunting ...

  4. 10 Biggest Business Mistakes That Every Entrepreneur Should Avoid

    原文链接:http://www.huffingtonpost.com/syed-balkhi/10-biggest-business-mista_b_7626978.html When I start ...

  5. 7 COMPELLING REASONS YOU NEED TO START THE BUSINESS YOU’VE ALWAYS WANTED

    原文链接:http://lesseesadvocate.com/7-compelling-reasons-need-start-business-youve-always-wanted/ Don’t ...

  6. business knowledge

    Finance knowledge Trading---At the core of our business model is Trading, which involves the buying ...

  7. Business Unit Lookup in Form

    Just add the below code in lookup() of StringEdit control in Form to get the Business Unit Lookup: p ...

  8. Office 365 系列一 ------- 如何单个安装Office 客户端和Skype for business

    当我们注册好或者购买好 Office 365后,我们的单个用户如何进行在线的.流式的方式安装好我们的客户端,特别是对于我们非IT部门来说,这是一个比较为难的事情, 经常需要我们的IT去到同事的电脑旁边 ...

  9. 更改 Skype for Business Online 的 Sip 地址以匹配UPN

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

随机推荐

  1. git 查看当前仓库地址以及设置新的仓库地址

    1.查看当前仓库地址 git remote show origin 2.设置新的仓库地址 1.先登录 gitlab 查看当前仓库地址: 执行修改地址命令 git remote set-url orig ...

  2. 佳能单反SDK 步骤

    EdsInitializeSDK(); EdsGetCameraList(&eclr);//获取相机列表 EdsGetChildCount(eclr, &camCount);  //获 ...

  3. Laravel 实现指定用户下的设备分页(与查询指定分类下的文章原理相同)

    <?php //控制器 namespace App\Http\Controllers\Api\User; use App\Http\Controllers\Controller; use Ill ...

  4. js获取图片信息

    网络图片: fetch(item.path).then(function(res){ // 计算图片大小 return res.blob() }).then(function(data){ conso ...

  5. jeesite直接登录——真实破解

    前台 后台 @RequiresPermissions("alarm:alarm:view")一定要注释 —————————————————————————————————————— ...

  6. beego中获取url以及参数的方式

    以下都全默认在controller下执行 获取当前请求的referer fmt.Println(this.Ctx.Request.Referer()) 输出:http://localhost:8080 ...

  7. 一篇文章让你彻底明白__getattr__、__getattribute__、__getitem__的用法与执行原理

    __getattr__ 在Python中,当我们试图访问一个不存在的属性的时候,会报出一个AttributeError.但是如何才能避免这一点呢?于是__getattr__便闪亮登场了 当访问一个不存 ...

  8. SQL语句复习【专题一】

    SQL语句复习[专题一] --创建用户 scott 并设置密码为 tiger create user scott identified by tiger --用户刚刚创建没有任何的权限,连登录的权限都 ...

  9. 论文笔记:Learning Region Features for Object Detection

    中心思想 继Relation Network实现可学习的nms之后,MSRA的大佬们觉得目标检测器依然不够fully learnable,这篇文章类似之前的Deformable ROI Pooling ...

  10. AD软件中可视栅格 捕捉栅格 电气栅格的功能和设置详解

    AD16的栅格设置 AD16系统共有3种栅格:可视栅格.电气栅格.捕捉栅格. Snap:捕获栅格,如果设定值是10mil,鼠标的光标拖动零件引脚,距离可视栅格在10mil范围之内时,零件引脚自动的准确 ...