Codeforces Round #588 (Div. 1) C. Konrad and Company Evaluation
直接建反边暴力 复杂度分析见https://blog.csdn.net/Izumi_Hanako/article/details/101267502
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = ;
ll out[MAXN], in[MAXN];
vector<int> G[MAXN];
int main() {
int n, m;
scanf("%d %d", &n, &m);
for (int i = ; i <= m; i++) {
int u, v;
scanf("%d %d", &u, &v);
if (u < v) {
swap(u, v);
}
out[u]++, in[v]++;
G[v].push_back(u);
}
ll ans = ;
for (int i = ; i <= n; i++) {
ans += out[i] * in[i];
}
cout << ans << endl;
int Q;
scanf("%d", &Q);
while (Q--) {
int x;
scanf("%d", &x);
ans -= out[x] * in[x];
out[x] += G[x].size(), in[x] = ;
for (int v : G[x]) {
ans -= out[v] * in[v];
out[v]--, in[v]++;
ans += out[v] * in[v];
G[v].push_back(x);
}
G[x].clear();
cout << ans << endl;
}
return ;
}
Codeforces Round #588 (Div. 1) C. Konrad and Company Evaluation的更多相关文章
- Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和
Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和 [Problem Description ...
- Codeforces Round #588 (Div. 2)
传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #defin ...
- Codeforces Round #588 (Div. 1) 简要题解
1. 1229A Marcin and Training Camp 大意: 给定$n$个对$(a_i,b_i)$, 要求选出一个集合, 使得不存在一个元素好于集合中其他所有元素. 若$a_i$的二进制 ...
- Codeforces Round #588 (Div. 2) E. Kamil and Making a Stream(DFS)
链接: https://codeforces.com/contest/1230/problem/E 题意: Kamil likes streaming the competitive programm ...
- Codeforces Round #588 (Div. 2) D. Marcin and Training Camp(思维)
链接: https://codeforces.com/contest/1230/problem/D 题意: Marcin is a coach in his university. There are ...
- Codeforces Round #588 (Div. 2) C. Anadi and Domino(思维)
链接: https://codeforces.com/contest/1230/problem/C 题意: Anadi has a set of dominoes. Every domino has ...
- Codeforces Round #588 (Div. 2) B. Ania and Minimizing(构造)
链接: https://codeforces.com/contest/1230/problem/B 题意: Ania has a large integer S. Its decimal repres ...
- Codeforces Round #588 (Div. 2) A. Dawid and Bags of Candies
链接: https://codeforces.com/contest/1230/problem/A 题意: Dawid has four bags of candies. The i-th of th ...
- Codeforces Round #588 (Div. 1)
Contest Page 因为一些特殊的原因所以更得不是很及时-- A sol 不难发现当某个人diss其他所有人的时候就一定要被删掉. 维护一下每个人会diss多少个人,当diss的人数等于剩余人数 ...
随机推荐
- CF1190D Tokitsukaze and Strange Rectangle
思路: 线段树 + 扫描线. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int n ...
- Java学习笔记-抽象类与接口
抽象类用于在类中不用具体实现,而在子类中去实现的类 抽象类 抽象类概述 抽象定义:抽象就是从多个事物中将共性的,本质的内容抽取出来 抽象类:Java中可以定义没有方法体的方法,该方法的具体实现由子类完 ...
- Guava源码阅读-base-Charsets
package com.google.common.base; 今天在找base包下的源码阅读时,看到了Charsets,肯定是定义字符集的类,本来就想简单的看一下.(部分内容摘抄自:http://b ...
- Linux中 cmake-3.x 编译安装以及man page添加
首先回顾一下 cmake-2.x 的编译安装. ================ cmake-2.x编译安装说明 ================编译安装的命令: ./bootstrap --pref ...
- 要求设计 LazyMan 类,实现以下功能
LazyMan('Tony'); // Hi I am Tony LazyMan('Tony').sleep(10).eat('lunch'); // Hi I am Tony // 等待了10秒.. ...
- [OpenCV] 图像亮度和对比度调整
对比度调整的原理参考这篇博客 以下是代码实现: #include <iostream> #include "opencv2/core.hpp" #include &qu ...
- class.forName 和 classLoader的区别
Java中的Class.forName()和ClassLoader都可以用来对类进行加载.Class.forName()除了将类的.class文件加载到JVM中 还会对类进行解释,执行类中的stati ...
- Django使用DataTables插件总结
Django使用Datatables插件总结 文章中的例子已上传至github 基本使用 Datatables插件是一款方便简单的展示数据的列表插件.关于基本使用,官方网站上的已介绍的很详细,这里我再 ...
- LC 94. Binary Tree Inorder Traversal
问题描述 Given a binary tree, return the inorder traversal of its nodes' values. (左 - 根 - 右) Example: In ...
- php实现算法
二分法查找(已排序) @params $arr 查找的数组 $start 开始查找的下标 $end 结束查找的下标 $value 查找的值 function bin_search($arr,$ ...