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 把一个点指向修改它会影响到的点就可以做了: 有取模,所以多出一些要注意的地方,首先是可能出现环,所以需要 ...
随机推荐
- C#内存管理—职场生存的必修课
前言 在职场中,确立自身的技术水平很重要,因为,如果你被标记成了技术菜鸟,那么你的工作一旦做快了,大家就会一致的认为这个任务比较简单:如果你未如期完成,则会被各种明嘲暗讽,你不但无法获得合理的表扬,还 ...
- [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 ...
- android <application> 开发文档翻译
由于本人英文能力实在有限,不足之初敬请谅解 本博客仅仅要没有注明"转",那么均为原创.转贴请注明本博客链接链接 <application>语法: <appl ...
- [转] 买彩票的利器--gun
源链接 还在自己买彩票吗,有个现成的:GNU shuf命令. shuf -i - -n | 这样就会产生两组彩票(1~36个数字任选) 当然还可以派其他用途,比如: shuf -e clubs hea ...
- UNIX网络编程学习(9)--getsockname和getpeername的用法及实例(转)
getsockname和getpeername #include <sys/socket.h>int getsockname(int sockfd, struct sockaddr *lo ...
- Sublime Text 3设置吊炸天PHP开发环境
@heiyeluren @created: 2016/5/31 @last modify: 2016/7/8 1. 下载安装Sublime Text 3 http://www.sublimetext. ...
- IDEA--java版本修改(jdk1.8改成jdk1.7)
转载:https://blog.csdn.net/huyishero/article/details/61916516
- struts2多图片上传实例【转】
原文地址:http://blog.csdn.net/java_cxrs/article/details/6004144 描述: 通过struts2实现多图片上传. 我使用的版本是2.2.1,使用的包有 ...
- Form content types
Forms in HTML documents https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 17.13.4 Form con ...
- POJ 3104 Drying (二分+精度)
题目链接:click here~~ [题目大意]: 题意:有一些衣服,每件衣服有一定水量,有一个烘干机,每次能够烘一件衣服,每分钟能够烘掉k单位水. 每件衣服没分钟能够自己主动蒸发掉一单位水, 用烘干 ...