map容器结构体离散化
来源:互联网 发布:网络推广专员吧 编辑:程序博客网 时间:2024/06/05 09:44
小数坐标离散化:
#include"string.h"#include"stdio.h"#include"iostream"#include"algorithm"#include"queue"#include"stack"#include"stdlib.h"#include"map"#include"string"#include"math.h"#define inf 10000000#define INF 0x3f3f3f3fconst double PI=acos(-1.0);const double r2=sqrt(2.0);const int M=100;const int N=1010*502*2;const double g=9.8;#define eps 1e-10using namespace std;struct node{ double x,y; node(){} node(double xx,double yy) { x=xx; y=yy; } bool operator<(const node &b)const { if(fabs(x-b.x)<eps) return y<b.y; else return x<b.x; }};int main(){ int n,i; while(scanf("%d",&n)!=-1) { map<node,int>mp; int cnt=0; for(i=1;i<=n;i++) { node e; scanf("%lf%lf",&e.x,&e.y); if(!mp[e]) mp[e]=++cnt; } double a,b; while(scanf("%lf%lf",&a,&b)!=-1) { node t(a,b); printf("%d\n",mp[t]); } }}
整数二维坐标离散化:
#include"string.h"#include"stdio.h"#include"iostream"#include"algorithm"#include"queue"#include"stack"#include"stdlib.h"#include"map"#include"string"#include"math.h"#define inf 10000000#define INF 0x3f3f3f3fconst double PI=acos(-1.0);const double r2=sqrt(2.0);const int M=100;const int N=1010*502*2;const double g=9.8;#define eps 1e-10using namespace std;struct node{ int x,y; node(){} node(int xx,int yy) { x=xx; y=yy; } bool operator<(const node &b)const { if(x==b.x) return y<b.y; else return x<b.x; }};int main(){ int n,i; while(scanf("%d",&n)!=-1) { map<node,int>mp; int cnt=0; for(i=1;i<=n;i++) { node e; scanf("%d%d",&e.x,&e.y); if(!mp[e]) mp[e]=++cnt; } int a,b; while(scanf("%d%d",&a,&b)!=-1) { node t(a,b); printf("%d\n",mp[t]); } }}
同理三维多维也可以:
#include"string.h"#include"stdio.h"#include"iostream"#include"algorithm"#include"queue"#include"stack"#include"stdlib.h"#include"map"#include"string"#include"math.h"#define inf 10000000#define INF 0x3f3f3f3fconst double PI=acos(-1.0);const double r2=sqrt(2.0);const int M=100;const int N=1010*502*2;const double g=9.8;#define eps 1e-10using namespace std;struct node{ int x,y,z; node(){} node(int xx,int yy,int zz) { x=xx; y=yy; z=zz; } bool operator<(const node &b)const { if(z==b.z) { if(y==b.y) return x<b.x; else return y<b.y; } else return z<b.z; }};int main(){ int n,i; while(scanf("%d",&n)!=-1) { map<node,int>mp; int cnt=0; for(i=1;i<=n;i++) { node e; scanf("%d%d%d",&e.x,&e.y,&e.z); if(!mp[e]) mp[e]=++cnt; } int a,b,c; while(scanf("%d%d%d",&a,&b,&c)!=-1) { node t(a,b,c); printf("%d\n",mp[t]); } }}
0 0
- map容器结构体离散化
- C++中stl容器map针对结构体的查找
- zoj3299 Fall the Brick map 离散化
- HDU 4941 Magical Forest 【离散化】【map】
- Hdu 4941 Magical Forest(map+离散化)
- hdoj4941Magical Forest【stl map+离散化】
- hdu 5233 Gunner II (map离散化)
- cf#345-C - Watchmen-map离散化
- UVA11991(map+vector 离散化处理)
- c++中map容器简单功能实现测试附带结构体指针测试
- 结构体容器vector
- map+结构体
- Map容器
- map容器
- map容器
- map容器
- map容器
- map容器
- Json的定义、标准格式及json字符串检验
- 关于Eclipse自定义启动画面和图标的方法
- Cts框架解析(6)-任务的执行
- 不同PAD适配的时候方法2
- easyui上下datagrid适应屏幕百分比
- map容器结构体离散化
- exit()和_exit()和return
- 什么是ANR,如何避免ANR
- JSP知识梳理
- oracle 定时器
- spring IOC原理诠释的比较好的例子--perfect
- 怎样做一名优秀的应用开发工程师
- linux_创建ext4文件
- mybatis实战教程(mybatis in action),mybatis入门到精通