https://codeforces.com/problemset/problem/1000/C 题意: 有n个线段,覆盖[li,ri],最后依次输出覆盖层数为1~n的点的个数. 思路: 区间线段覆盖问题,第一反应树状数组.线段树,看了看数据规模,开不了这么大的空间. 只能用差分了  代码如下: #include <stdio.h> #include <string.h> #include <iostream> #include <string> #incl…
题目:戳这里 题意:给出n个线段,问被1~n个线段覆盖的点分别有多少. 解题思路: 这题很容易想到排序后维护每个端点被覆盖的线段数,关键是端点值不好处理.比较好的做法是用差分的思想,把闭区间的线段改为前闭后开,同时在求总点数的时候,也按前闭后开的区间来求,这样就巧妙避开了两个端点之间的讨论,只用维护好一个端点就行了. 代码比文字更容易理解: 1 #include <bits/stdc++.h> 2 #define lowbit(x) x&-x; 3 typedef long long…
考虑如果数字范围没有这么大的话,直接做一个差分数组就可以了 但现在变大了 所以要用一个map来维护 #include<bits/stdc++.h> #define pa pair<int,int> #define CLR(a,x) memset(a,x,sizeof(a)) using namespace std; typedef long long ll; ; inline ll rd(){ ll x=;; ;c=getchar();} +c-',c=getchar(); ret…
C - Covered Points Count CodeForces - 1000C You are given nn segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each othe…
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…
C. Covered Points Count time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given nn segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segment…
 Covered Points Count time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given nn segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments…
点此看题面 大致题意: 给出\(n\)条线段,分别求有多少点被覆盖\(1\)次.\(2\)次...\(n\)次. 正常的算法 好吧,这道题目确实有个很简单的贪心做法(只可惜我做的时候没有想到,结果想了半天只想出一个无比麻烦的),这里介绍一个稍微有些复杂的. 不正常的算法(我的算法) 考虑离散化每一个出现过的点以及这些点后面的点(之所以要离散化这些后面的点,是为了方便后面的差分). 假如我们用\(p[i]\)来表示原来为\(i\)的数离散化后的值,并用\(q[i]\)表示离散化后值为\(i\)的数…
Bryce1010模板 http://codeforces.com/problemset/problem/1000/C 题意:问你从[l,r]区间的被多少条线覆盖,列出所有答案. 思路:类似括号匹配的做法 #include <bits/stdc++.h> using namespace std; #define ll long long const ll MAXN=2e5+10; struct Node { ll num; ll dir;//0左1右 //ll cnt; }node[MAXN*…
又一次写起了几何.... 特殊处理在于有可能出现多条线段交于一点的情况,每次考虑时,对每条线段与其他所有线段的交点存在一个set里,对每一个set,每次删除set.size()即可 重点在于判断两条线段的交点是否是一个整数点,需要特殊考虑,平行和y=kx+b关系式不能成立的情况 我的代码中没有判断除数为0的情况(因为不会报错,我也就没写23333,但不影响结果 #include<iostream> #include<cstdio> #include<cmath> #in…