题目链接:传送门

很好的思路
读完题目想一想
倒着建边会比较好处理
因为删边的处理比加边要容易
所以离线下来倒着搞就可以了

/*** @Date:   2019-04-14T10:03:39+08:00* @Last modified time: 2019-04-14T10:03:39+08:00*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <algorithm>
#include <climits>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define A 1000010
#define B 2010using namespace std;
typedef long long ll;
struct node {int next, to;
}e[A];
int head[A], num;
void add(int fr, int to) {e[++num].next = head[fr];e[num].to = to;head[fr] = num;
}
int ans, n, m, k, del[A], in[A], a[A], b[A], out[A];
map<pair<int, int>, bool> mm;
void work(int x) {queue<int> q; q.push(x);if (in[x] >= k or del[x]) return;del[x] = 1; ans--;while (!q.empty()) { //踢出能遍历到的所有不符合条件的点int fr = q.front(); q.pop();for (int i = head[fr]; i; i = e[i].next) {int ca = e[i].to;if (del[ca]) continue;if (!mm[make_pair(fr, ca)]) in[ca]--;if (in[ca] < k) {ans--; q.push(ca); del[ca] = 1;}}}
}int main(int argc, char const *argv[]) {cin >> n >> m >> k; ans = n;for (int i = 1; i <= m; i++) {cin >> a[i] >> b[i];add(a[i], b[i]); add(b[i], a[i]);in[a[i]]++; in[b[i]]++;}for (int i = 1; i <= n; i++) work(i);for (int i = m; i >= 1; i--) {out[i] = ans;if (!del[a[i]]) in[b[i]]--;if (!del[b[i]]) in[a[i]]--;mm[make_pair(a[i], b[i])] = mm[make_pair(b[i], a[i])] = 1;work(a[i]); work(b[i]);}for (int i = 1; i <= m; i++) cout << out[i] << endl;
}

CF1037E Trips相关推荐

  1. CF1037E. Trips

    题目链接 CF1037E. Trips 题解 每次删点后,对不满足要求的点拓扑 代码 #include<map> #include<queue> #include<vec ...

  2. [Manthan, Codefest 18][Codeforces 1037E. Trips]

    题目链接:1037E - Trips 题目大意:有n个人,m天,每天晚上都会有一次聚会,一个人会参加一场聚会当且仅当聚会里有至少k个人是他的朋友.每天早上都会有一对人成为好朋友,问每天晚上最多能有多少 ...

  3. LeetCode Trips and Users(关联、分组,聚合)

    给出trips和users表 CREATE TABLE `trips` (   `Id` int(11) DEFAULT NULL,   `Client_Id` int(11) DEFAULT NUL ...

  4. Codechef TRIPS Children Trips (分块、倍增)

    题目链接: https://www.codechef.com/problems/TRIPS 感觉CC有点毒瘤啊.. 题解: 首先有一个性质可能是因为太傻所以网上没人解释,然而我看了半天: 就是正序和倒 ...

  5. 一二三系列之CodeChef分块——Chef and Churu,Chef and Problems,Children Trips

    文章目录 Chef and Churu source solution code Chef and Problems source solution code Children Trips sourc ...

  6. [CodeChef Trips]Children Trips

    Children Trips 题解 关于这种跳跃的**题,当它PPP值很大时几次就可以跳到目标节点了,而较小时却会跳很久,所以我们很快就可以想到对询问分类处理. 对于P>nP>\sqrt{ ...

  7. Codeforces - Trips

    题目链接:Codeforces - Trips 加边不好想,所以我们直接反向删边. 每次删除一条边,那么对应两个点的度都减1,每次都把度小于k的删掉,剩下的点就是答案. 删点直接标记即可,删边在set ...

  8. Trips and Users

    Trips and Users The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and ...

  9. [CC-TRIPS]Children Trips

    [CC-TRIPS]Children Trips 题目大意: \(n(n\le10^5)\)座城市构成一棵树,且树上的每条边的长度\(l_i\)满足\(1\le l_i\le 2\).\(m(m\le ...

最新文章

  1. (第一次)NODEJS学习笔记
  2. 【收藏】maven跳过单元测试-maven.test.skip和skipTests的区别
  3. 计算机科技手抄报内容,科技手抄报内容云计算文字稿
  4. Windows Update Error: 80244019
  5. php 转义取消,php如何取消转义
  6. python多目标跟踪卡尔曼滤波_卡尔曼多目标跟踪的例子?
  7. STM32CubeMX软件工程描述_USART配置过程
  8. 中小企业信息管理 巧用E-Cell
  9. Activity的Launch mode详解 singleTask正解
  10. phpstorm内网远程debug
  11. 编译内核_Linux内核编译(自己实现的网卡上面测试c1000k案例)
  12. UCGUI的消息处理
  13. 计算机控制实验室装置,自控/计控原理实验箱 实验仪 实验装置 教学实训设备...
  14. screentogif能录制声音吗_一款免费且强大的gif动画录制工具,再也不愁录动画!...
  15. Texstduio+Miktex遇到ntx-Italic-tlf-t1 could not be created问题
  16. 心情整天都在郁闷浮云往事如云烟,撕心裂肺:伤感心情日志
  17. 自己写的vue图片上传插件(假装是插件)
  18. 明翰经验系列之管理篇V1.1(持续更新)
  19. 前Vertu设计师推出Android版iBeacon,无需专有硬件,没话费的旧手机都能做基站
  20. Python将图片转换为字符画

热门文章

  1. 2016文件储存服务器,测试Windows Server 2016存储池教程
  2. Java编程基础二:java基本语法
  3. Python 打印阿姆斯特朗数
  4. 仿微信、微博发朋友圈,文字+图片+视频
  5. 加快Kettle插入速度的小技巧
  6. 写给人类的机器学习 六、最好的机器学习资源
  7. 第一卷 第一百三十六章 好白菜
  8. Gitlab回滚到上次提交
  9. Anyconnect Server 搭建
  10. Linux打印一个文字logo