-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMap with custom key.cc
86 lines (73 loc) · 1.89 KB
/
Map with custom key.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
using namespace std;
#define FOR( i, L, U ) for(int i=(int)L ; i<=(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define SQR(x) ((x)*(x))
#define INF INT_MAX
#define READ(filename) freopen(filename, "r", stdin);
#define WRITE(filename) freopen(filename, "w", stdout);
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<vector<int> > vvc;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<string, string> mss;
typedef map<string, char> msc;
#define WHITE 0
#define GRAY 1
#define BLACK 2
struct Point{
int x;
int y;
Point(){y = x = 0;}
Point(int y, int x){
this->y = y;
this->x = x;
}
bool operator < (Point a){
if(this->x != a.x)return this->x < a.x;
return this->y < a.y;
}
};
bool operator < (Point a, Point b){
if(a.x != b.x )return a.x < b.x;
return a.y < b.y;
}
int main()
{
//READ("input.txt");
//WRITE("output.txt");
map<Point,bool> h;
Point a = Point(1,2);
h[a] = true;
h[Point(2,3)] = true;
h[Point(2,2)] = true;
map<Point, bool> :: iterator it;
for(it = h.begin(); it != h.end(); it++) cout << (*it).first.x << " " << (*it).first.y << endl;
if(h[Point(2,5)])cout << "found" << endl;
else cout << "not found" << endl;
for(it = h.begin(); it != h.end(); it++) cout << (*it).first.x << " " << (*it).first.y << endl;
return 0;
}