Data Center Maintenance CodeForces - 950E
http://codeforces.com/contest/950/problem/E
贴一份板子
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
struct E
{
int to,nxt;
}e[];
int f1[],ne,a[],sccc,sccnum[],top,dfn[],low[],dfsc;
int s[],n,m,h,ou[],anss=0x3f3f3f3f,ans1;
vector<int> sccx[];
void me(int u,int v)
{
e[++ne].to=v;
e[ne].nxt=f1[u];
f1[u]=ne;
} void dfs(int u)
{
dfn[u]=low[u]=++dfsc;
s[++top]=u;
for(int k=f1[u],v;k!=;k=e[k].nxt)
{
v=e[k].to;
if(!dfn[v])
{
dfs(v);
low[u]=min(low[u],low[v]);
}
else if(!sccnum[v])
low[u]=min(low[u],dfn[v]);
}
if(low[u]==dfn[u])
{
sccc++;
while(top&&s[top]!=u) sccnum[s[top--]]=sccc;
sccnum[s[top--]]=sccc;
}
} int main()
{
int c1,c2,i,k;
scanf("%d%d%d",&n,&m,&h);
for(i=;i<=n;i++) scanf("%d",&a[i]);
for(i=;i<=m;i++)
{
scanf("%d%d",&c1,&c2);
if((a[c1]+)%h==a[c2]) me(c1,c2);
if((a[c2]+)%h==a[c1]) me(c2,c1);
}
for(i=;i<=n;i++)
if(!dfn[i])
dfs(i);
for(i=;i<=n;i++)
for(k=f1[i];k!=;k=e[k].nxt)
if(sccnum[e[k].to]!=sccnum[i])
ou[sccnum[i]]++;
for(i=;i<=n;i++)
sccx[sccnum[i]].push_back(i);
//printf("%da\n",ou[1]);
for(i=;i<=sccc;i++)
if(ou[i]==&&sccx[i].size()<anss)
{
anss=sccx[i].size();
ans1=i;
}
printf("%d\n",anss);
for(i=;i<anss;i++) printf("%d ",sccx[ans1][i]);
return ;
}
Data Center Maintenance CodeForces - 950E的更多相关文章
- Codeforces 950.E Data Center Maintenance
E. Data Center Maintenance time limit per test 1 second memory limit per test 512 megabytes input st ...
- Codeforces Round #469 (Div. 1) 949C C. Data Center Maintenance (Div. 2 950E)
题 OvO http://codeforces.com/contest/949/problem/C codeforces 949C 950E 解 建图,记原图为 G1,缩点,记缩完点后的新图为G2 缩 ...
- Codeforces 950E Data Center Maintenance 强连通分量
题目链接 题意 有\(n\)个信息中心,每个信息中心都有自己的维护时间\((0\leq t\lt h)\),在这个时刻里面的信息不能被获得. 每个用户的数据都有两份备份,放在两个相异的信息中心(维护时 ...
- Codeforces 950E Data Center Maintenance ( 思维 && 强连通分量缩点 )
题意 : 给出 n 个点,每个点有一个维护时间 a[i].m 个条件,每个条件有2个点(x,y)且 a[x] != a[y].选择最少的 k (最少一个)个点,使其值加1后,m个条件仍成立. 分析 : ...
- Codeforces Round #469 (Div. 2) E. Data Center Maintenance
tarjan 题意: 有n个数据维护中心,每个在h小时中需要1个小时维护,有m个雇主,他们的中心分别为c1,c2,要求这两个数据中心不能同时维护. 现在要挑出一个数据中心的子集,把他们的维护时间都推后 ...
- codeforces 949C - Data Center Maintenance【tarjan】
首先转换图论模型,把某个客户一个终端的维修时间(+1)%h之后和另一个终端维修时间一样,这样的两个终端连一条有向边,表示推后一个终端就必须推后另一个 然后tarjan缩点,一个scc里的终端是要一起推 ...
- Codeforces 949C(Data Center Maintenance,Tarjan缩点)
难度系数:1900 graphs 题意:有 n 个银行,m 个客户,每个客户都把自己的资料放在 2 个银行,一天总共有 h 小时,每个银行每天都要维护一小时,这一小时内银行无法工作,但是这一小时客户仍 ...
- CF 949C Data Center Maintenance——思路+SCC
题目:http://codeforces.com/contest/949/problem/C 可以想到可能是每组c有连边的可能. 但别直接给c1.c2连边,那样之后会变得很不好做. 可以把一些限制放在 ...
- CF949 C Data Center Maintenance——边双连通分量
题目:http://codeforces.com/contest/949/problem/C 把一个点指向修改它会影响到的点就可以做了: 有取模,所以多出一些要注意的地方,首先是可能出现环,所以需要 ...
随机推荐
- 一例Ext4文件系统fsck后损坏的修复过程
1.故障发生背景 Ext4文件系统没有umount下来,之后做了fsck操作检查一致性,结果导致Ext4文件mount不上(有时也会表现为导致目录变成了文件). 报错提示信息:mount: wrong ...
- [Angular] Modify User Provided UI with Angular Content Directives
If we’re going to make our toggle accessible, we’ll need to apply certain aria attributes to the con ...
- VM Workstation的Unity Mode有什么用
正常情况下,如果我启动了一个VM Workstaion的虚拟机,比如是一个Linux系统,并且没运行任何软件,进入Unity mode之后,我真实系统的左下角会有一个虚拟机的图标 点击这个图标可以打开 ...
- 【LeetCode】Swap Nodes in Pairs 链表指针的应用
题目:swap nodes in pairs <span style="font-size:18px;">/** * LeetCode Swap Nodes in Pa ...
- Windows下的Jupyter Notebook 的介绍(写给新手)(图文详解)
不多说,直接上干货! Windows下的Python 3.6.1的下载与安装(适合32bits和64bits)(图文详解) Windows下的Jupyter Notebook 安装与自定义启动(图文详 ...
- Effective C++学习笔记(Part Two:Item 5-12)
近期最终把effectvie C++细致的阅读了一边,非常惊叹C++的威力与魅力.近期会把近期的读书心得与读书笔记记于此.必备查找使用,假设总结有什么不当之处,欢迎批评指正: 如今仅仅列出框架. ...
- 使用Java对100以内偶数求和
/** * 根据for循环的描述: for(变量初始化:循环条件:修改循环变量的值),求出100以内的所有偶数,for(int i = 0; i<=100; i+=2),把这些偶数累加到一个空的 ...
- MySQL 高可用架构在业务层面细化分析研究
相对于传统行业的相对服务时间9x9x6或者9x12x5,由于互联网电子商务以及互联网游戏的实时性,所以服务要求7*24小时,业务架构无论是应用还是数据库,都须要容灾互备.在mysql的体系中,最好通过 ...
- What Is the Linux Lokkit Utility? https://www.lifewire.com/what-is-lokkit-2192255
lokkit: The Lokkit utility attempts to provide firewalling for the average Linux end user. Instead o ...
- 运行tomcat6w.exe ,提示 指定的服务未安装 unable to open the service 'tomcat6'
错误:运行tomcat6w.exe ,提示 指定的服务未安装 unable to open the service 'tomcat6'(我用的是官网下载的解压版) 解决方法: 打开命令行提示符窗口=& ...