直接建反边暴力 复杂度分析见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的更多相关文章

  1. 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 ...

  2. Codeforces Round #588 (Div. 2)

    传送门 A. Dawid and Bags of Candies 乱搞. Code #include <bits/stdc++.h> #define MP make_pair #defin ...

  3. Codeforces Round #588 (Div. 1) 简要题解

    1. 1229A Marcin and Training Camp 大意: 给定$n$个对$(a_i,b_i)$, 要求选出一个集合, 使得不存在一个元素好于集合中其他所有元素. 若$a_i$的二进制 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. Codeforces Round #588 (Div. 1)

    Contest Page 因为一些特殊的原因所以更得不是很及时-- A sol 不难发现当某个人diss其他所有人的时候就一定要被删掉. 维护一下每个人会diss多少个人,当diss的人数等于剩余人数 ...

随机推荐

  1. 如何在ubuntu下重建被grub覆盖的win10引导区?

    如何在ubuntu下重建被grub覆盖的win10引导区? 1.修改grub配置文件: sudo vi /etc/default/grub 2.设置:GRUB_DEFAULT = 2 3.更新配置文件 ...

  2. Hackergame2019 web

    前几天跟着几个大佬一起看了看中科大的Hackergame2019,这个比赛主要针对的是新手,激发新生对CTF比赛的兴趣,虽然我已经大三了,但实在是因为我过于five,也只能帮大佬打打杂,这里把自己做的 ...

  3. eNSP使用-不同网段的互联

    就像下面这个场景: 1.基本配置 先点击左上角的——新建 然后咱们把要用的设备都拖到面板上去 成品就是这样的: 点击这个为他们添加备注 我们来配置一下实验编址 右键单击PC1设置(PC2同理,就不多演 ...

  4. codevs 1163:访问艺术馆

    题目描述 Description 皮尔是一个出了名的盗画者,他经过数月的精心准备,打算到艺术馆盗画.艺术馆的结构,每条走廊要么分叉为二条走廊,要么通向一个展览室.皮尔知道每个展室里藏画的数量,并且他精 ...

  5. Java核心1(第三章)

    3.6字符串 子串substring(a,b)方法    第二个参数是不想复制的第一个位置  可以从一个较大的字符串中提取一个子串 3.6.2拼接  Java允许使用+号链接两个字符串 3.6.3不可 ...

  6. vue中的axios.post使用json数据传输,出现请求头字段内容类型是不被允许的情况的解决方案

    如何解决出现AXIOS的Request header field Content-Type is not allowed by Access-Control-Allow-Headers in pref ...

  7. IDEA操作之FileHeager设置

    作用:头部注释添加,一般用于记录类的创建者等信息. 1. 打开配置 File->Settings->Editor->File and Code Templates->Inclu ...

  8. Oulipo POJ - 3461(kmp,求重叠匹配个数)

    Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, w ...

  9. 【模板】C++高精度加法

    所谓高精度加法就是对两个和可能会超过long long数据范围的数进行加法运算.这种情况下,显然不能使用常规的方法进行运算. 那么,不妨考虑一下人在纸上是如何进行加法运算的.当人进行加法运算时,通常会 ...

  10. 第七章 ZYNQ-MIZ701 GPIO使用之EMIO

    7.0难度系数★☆☆☆☆☆☆ 7.1硬件截图 7.1.1 PCB上的位置 7.1.1 PCB上的位置 7.2电路分析 本次实验用到的是LD_A0~LD_A3,管脚定义如下表所示. LD_A0:F17 ...