ChangChun_1002 Alice and Bob (HDU 4268)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<vector>
#include<string>
#include<map>
using namespace std;

#define pb push_back //强大的初始define; 
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORD(i,a,b) for (int i=(a); i>=(b); i--)
#define REP(i,b) FOR(i,0,b)
#define sf scanf
#define pf printf
#define Maxn 100100

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<int>::iterator vit;

int n, ans;
pii a[Maxn], b[Maxn];
multiset<int> s; //数据结构,平衡树什么的,果然很强大! 
int main() {
    int T;
    sf("%d", &T);
    while (T--) {
        s.clear();
        sf("%d", &n);
        REP(i, n) {
            sf("%d%d", &a[i].fi, &a[i].se);
        }
        REP(i, n) {
            sf("%d%d", &b[i].fi, &b[i].se);
        }
        sort(a, a+n);
        sort(b, b+n);
        int p = 0;
        ans = 0;
        for (int i = 0; i < n; ++i) {
            while (p < n && b[p].fi <= a[i].fi) { //如果a[i]能覆盖住b[p],将b[p]
            //加入mtset中; 
                s.insert(b[p].se); 
                p++;
            }
            if (s.size() >= 1) {
                multiset<int>::iterator it = s.lower_bound(a[i].se); //指向mtset
                //中第一个比a[i].se 大的元素的位置; 
                if (it == s.end()) it--; //如果set找不到一个数>=a.se的话,返回的
                //迭代器是指向set.end()的,而这个地方事实上是没值的所以必须-1;
                if (it != s.begin() && *it > a[i].se) it--; //-1是因为我要找的数
                //必须是<=a.se; 
                if (*it <= a[i].se ) {
                    s.erase(it);
                    ans++;
                }
            }
        }
        pf("%d\n", ans);
    }
    return 0;
}

/* 说下 lower_bound 和 upper_bound:
 * 他们的返回值分别是 L 和 R ,则 v 出现的子序列为  [ L , R ) ,这个结论当v 不存在
 * 时也成立;此式 L = R ,区间为空;
 */ 



 

在MATLAB中绘制长春市的地图,你需要首先获取相关的地图数据,通常包括地理坐标数据(经度和纬度)。如果你没有现成的数据,可以考虑使用一些在线资源提供的地理编码服务(如Google Maps API或Bing Maps API),将长春市的具体地点转换为经纬度。 以下是基本步骤: 1. **安装地图支持包**: 如果你还没有安装,需要安装`geobubble`或其他地图可视化工具包,如`mapdata`或`geoplot`. ```matlab % 如果没有安装,运行以下代码 if ~exist('geobubble', 'file') addpath(genpath(matlabroot+'/toolbox/map.toolbox')); end ``` 2. **获取地图数据**: 使用`geocode`函数从网上获取长春市的经纬度数据,例如长春市政府位置。 ```matlab changchun_location = geocode('Changchun Municipal Government'); [changchun_lat, changchun_lon] = deal(changchun_location.Latitude, changchun_location.Longitude); ``` 3. **加载中国地图数据**: 要显示特定区域的地图,MATLAB有一些预设的世界地图数据,也可以使用第三方数据集。使用`loadmap`加载中国的地图数据。 ```matlab load(mapdata.MapData); worldmap = usamap; ``` 4. **绘制地图**: 将获取到的长春市经纬度添加到地图上,并设置范围。 ```matlab figure bubble(map=worldmap, positions=[changchun_lon changchun_lat], radii=ones(size(changchun_lon)),... markerfacecolor='red', MarkerEdgeColor='black', hold on); geobubble([worldmap.Lon; changchun_lon], [worldmap.Lat; changchun_lat]); xlim([-180 180]) ylim([-90 90]) % 显示城市名称 text(changchun_lon(1), changchun_lat(1), 'Changchun City', 'HorizontalAlignment', 'center'); % 显示地图边界范围 lonlims = worldmap.XLim; latlims = worldmap.YLim; hold off ``` 这只是一个基础示例,实际操作中可能需要根据实际情况调整地图比例尺和详细程度。如果你无法获取实时经纬度数据,可以使用固定的城市点作为示例。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值