2018-2019 ACM-ICPC, Asia East Continent Final L Eventual … Journey
#include<iostream>
using namespace std;
const int MAX=2e5+;
int cnt[MAX];
int ans[MAX];
int a[MAX];
int main() {
int n,m,zero=,one=;
cin>>n>>m;
for(int i=; i<=n; i++) {
scanf("%d",&a[i]);
if(a[i]==)zero++;
else one++;
}
while(m--) {
int x,y;
scanf("%d%d",&x,&y);
if(a[x]!=a[y]) {
cnt[x]++;//记录每个点的桥
cnt[y]++;
}
}
int A=,B=;
for(int i=; i<=n; i++) {
if(a[i]==&&cnt[i])A++;//0类,而且有桥,
if(a[i]==&&cnt[i])B++;//1类,数量
}
for(int i=; i<=n; i++) {
ans[i]+=cnt[i];//与异类相连的桥的数目,也就是步数
if(a[i]==)ans[i]+=zero-;//加同类
else ans[i]+=one-;//同类
if(cnt[i]==) {//如果 这个站没有建桥
if(a[i]==) {//如果是0类
ans[i]+=*B;//一个点只算建在上面的一座桥,其他为在一个点上重复建桥的
ans[i]+=*(one-B);//
} else {
ans[i]+=*A;
ans[i]+=*(zero-A);
}
} else {//如果这个点建桥了
if(a[i]==)ans[i]+=*(one-cnt[i]);
//如果是0类, 那么到1类的其他点的距离就是2
else ans[i]+=*(zero-cnt[i]);
}
}
for(int i=; i<=n; i++)
cout<<ans[i]<<" ";
return ;
}
2018-2019 ACM-ICPC, Asia East Continent Final L Eventual … Journey的更多相关文章
- 2019 ACM/ICPC Asia Regional shanxia D Miku and Generals (二分图黑白染色+01背包)
Miku is matchless in the world!” As everyone knows, Nakano Miku is interested in Japanese generals, ...
- 2016 ACM/ICPC Asia Regional Shenyang Online 1009/HDU 5900 区间dp
QSC and Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- hdu 5444 Elven Postman(二叉树)——2015 ACM/ICPC Asia Regional Changchun Online
Problem Description Elves are very peculiar creatures. As we all know, they can live for a very long ...
- (二叉树)Elven Postman -- HDU -- 54444(2015 ACM/ICPC Asia Regional Changchun Online)
http://acm.hdu.edu.cn/showproblem.php?pid=5444 Elven Postman Time Limit: 1500/1000 MS (Java/Others) ...
- 2015 ACM/ICPC Asia Regional Changchun Online HDU 5444 Elven Postman【二叉排序树的建树和遍历查找】
Elven Postman Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...
- hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...
- hduoj 4715 Difference Between Primes 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Time Limit: 2000/1000 MS (J ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
随机推荐
- ajax请求携带cookie和自定义请求头header
参考链接:https://blog.csdn.net/menghuanzhiming/article/details/102736312
- 牛客网剑指offer第19题——顺时针打印矩阵
这个题看似很简单: 题目: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下4 X 4矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 ...
- c#Socket通信基本使用
基本流程 Server private void btnStart_Click(object sender, EventArgs e) { try { //当点击开始监听时在服务器端创建一个负责监视I ...
- MySQL manager or server PID file could not be found!
[root@centos var]# service mysqld stop MySQL manager or server PID file could not be found! [F ...
- centos系统mongodb安装
使用腾讯云搭服务器时,需要链接数据库,就从头开始重新安装了一遍mongodb,没想到这么麻烦,记得之前没这么麻烦. 1.下载mongodb(一篇博客的) 安装的是3.6版本 `` vim /etc/y ...
- Disharmony Trees HDU - 3015 树状数组+离散化
#include<cstdio> #include<cstring> #include<algorithm> #define ll long long using ...
- PAT (Basic Level) Practice (中文)1041 考试座位号 (15 分)
每个 PAT 考生在参加考试时都会被分配两个座位号,一个是试机座位,一个是考试座位.正常情况下,考生在入场时先得到试机座位号码,入座进入试机状态后,系统会显示该考生的考试座位号码,考试时考生需要换到考 ...
- python3练习100题——049
题目:使用lambda来创建匿名函数. sum=lambda x,y:x+y from functools import reduce reduce(sum,[1,2,3,4,5])
- windows10 node-gyp安装
本机环境:win10,已安装vs2017,Node版本 10.13.0 1.安装node-gyp npm install -g node-gyp 2.安装完毕之后node-gyp list看一下 no ...
- HTML与W3C
HTML:超文本标记语言 超文本包括:文字.图片.音频.视频.动画等 流程:写好HTML代码后通过浏览器(自动编译HTML代码)展现出效果 HTML优点: 世界知名浏览器厂商对HTML5的支持 微软 ...