Educational Codeforces Round 46 C - Covered Points Count
emmm 好像是先离散化一下 注意 R需要+1 这样可以确定端点
emmm 扫描线?瞎搞一下?
#include<bits/stdc++.h>
using namespace std;
#define maxn 4000005
#define LL long long
LL a[maxn],b[maxn],ll[maxn],rr[maxn],c[maxn];
LL x[maxn],y[maxn];
vector<LL >q;
int main(){
LL n;
cin>>n;
;j<n;j++){
cin>>a[j]>>b[j];
b[j]++;
q.push_back(a[j]);
q.push_back(b[j]);
}
q.push_back();
sort(q.begin(),q.end());
q.erase(unique(q.begin(),q.end()),q.end());
;j<n;j++){
LL i=lower_bound(q.begin(),q.end(),a[j])-q.begin();
LL k=lower_bound(q.begin(),q.end(),b[j])-q.begin();
//x[j]=i,y[j]=k;
ll[i]++;
rr[k]++;
}
LL ans=;
LL i=;
memset(c,,sizeof(c));
memset(y,,sizeof(y));
;j<q.size();j++){
) x[j]+=ll[j]-rr[j];
];
// cout<<x[j]<<endl;
}
;j<q.size()-;j++){
// cout<<x[j]<<" "<<q[j+1]<<" "<<q[j]<<endl;
y[x[j]]+=q[j+]-q[j];
}
;j<=n;j++){
cout<<y[j]<<" ";
}
cout<<endl;
}
Educational Codeforces Round 46 C - Covered Points Count的更多相关文章
- Educational Codeforces Round 46 (Div 2) (A~G)
目录 Codeforces 1000 A.Codehorses T-shirts B.Light It Up C.Covered Points Count(差分) D.Yet Another Prob ...
- 【Codeforces】Educational Codeforces Round 46(Contest 1000)
题目 传送门:QWQ A:Codehorses T-shirts 题意: 给定一些字符串表示去年和今年的衣服型号大小( XL XXL M...... ),要求用最少的次数把去年的衣服大小改成今年需要的 ...
- Educational Codeforces Round 46 (Rated for Div. 2)
A - Codehorses T-shirts 思路:有相同抵消,没有相同的对答案+1 #include<bits/stdc++.h> #define LL long long #defi ...
- Educational Codeforces Round 46 (Rated for Div. 2) C. Covered Points Count
Bryce1010模板 http://codeforces.com/problemset/problem/1000/C 题意:问你从[l,r]区间的被多少条线覆盖,列出所有答案. 思路:类似括号匹配的 ...
- Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses
Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #in ...
- Educational Codeforces Round 46 (Rated for Div. 2) B. Light It Up
Bryce1010模板 http://codeforces.com/problemset/problem/1000/B 思路:先用两个数组sumon[]和sumoff[]将亮着的灯和灭的灯累计一下. ...
- Educational Codeforces Round 46 (Rated for Div. 2) A. Codehorses T-shirts
Bryce1010模板 http://codeforces.com/problemset/problem/1000/A 题意: 问你将一种类型的衣服转换成另一种的最小次数. #include<b ...
- Educational Codeforces Round 64 C. Match Points 【二分思想】
一 题面 C. Match Points 二 分析 根据题意很容易想到要去找满足条件的数,因为可以打乱输入的顺序,所以很容易想到二分. 但是如果直接对输入的数组进行二分,如输入$a$,直接在数组里二分 ...
- Educational Codeforces Round 46 (Rated for Div. 2) D. Yet Another Problem On a Subsequence
这个题是dp, dp[i]代表以i开始的符合要求的字符串数 j是我们列举出的i之后一个字符串的开始地址,这里的C是组合数 dp[i] += C(j - i - 1, A[i]] )* dp[j]; # ...
随机推荐
- node错误中间件处理 express类 带有路由操作
let express = require('express'); let app = new express(); let bodyParser = require('body-parser'); ...
- Chrome 离线安装插件的办法
参考url 学习网址 https://blog.csdn.net/weixin_39068791/article/details/81411938 插件下载地址: http://www.lanfans ...
- HDU 5898 odd-even number
题目:odd-even number 链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5898 题意:给一个条件,问l 到r 之间有多少满足条件的 ...
- Django Rest framework 框架
一.开发模式: 1. 普通开发方式(前后端放在一起写) 2. 前后端分离(前后台通过ajaxo交互) 后端(django rest framework写的) <----ajaxo---> ...
- git的简单使用(一些小操作,持续更新)
第一次使用git的过程记录 参考了两个文章 菜鸟教程-git简明指南 阮一峰-常用git命令清单 git的几个工作区(此处参考了上面的两篇介绍) 简单步骤如下 git init 在当前目录建立工作区 ...
- String、StringBuffer、StringBuilder三种类型的一点比较
简要记一点 以运行速度来说: StringBuilder>StringBuffer>String 以线程安全来说: StringBuilder线程不安全,而StringBuffer线程安全 ...
- DBExpress动态连接SQL-Server
procedure TForm1.Button1Click(Sender: TObject);var theCNN : TSQLConnection;//定义连接,要引用 DB, SqlExprbe ...
- python易混易乱(1)
字典 基础操作 <1>keys my_dict = {"name":"zhangsan","age":18} res = my_ ...
- powerdesigner 16.5 不允许有扩展属性,或对象不存在
创建完之后这边会出现 选择刚创建的用户 这样就可以了
- css的特性
一.继承性: 继承是一种规则,它允许样式不仅应用于某个特定html标签元素,而且应用于其后代. /* 不具有继承性的css样式: */p{border:1px solid red;} 二.特殊性(优先 ...