-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMACRO.cpp
More file actions
196 lines (156 loc) · 4.96 KB
/
MACRO.cpp
File metadata and controls
196 lines (156 loc) · 4.96 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include <bits/stdc++.h>
#define khela_hope int main (void)
#define khela_sesh return 0
#define ll long long
#define ull unsigned long long
#define db double
#define ull unsigned long long
#define MIN INT_MIN
#define MAX INT_MAX
#define all(x) (x).begin(), (x).end()
#define ii pair <int,int>
#define iii pair <int,ii>
#define pll pair <ll,ll>
#define plll pair <ll,pll>
#define ff first
#define ss second
#define minQueue priority_queue <int,vector<int>,greater<int> >
#define maxQueue priority_queue<int,vector<int>,less<int> >
#define pb push_back
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define GCD(x,y) __gcd((x), (y))
#define LCM(x,y) ((x / GCD((x), (y))) * y)
#define loop(a,n) for(int i=a; i<n; i++)
#define mem(x,y) memset((x), (y), sizeof (x));
#define Case int T; scanf("%d", &T); for(int cas = 1; cas <= T; ++cas)
#define pf printf
#define sf scanf
#define pr1(x) cout << x << endl
#define pr2(x,y) cout << x << ' ' << y << endl
#define powerOfTwo(x) (x && !(x & (x - 1)))
#define Iterator(type) type <int> :: iterator
#define mapIterator map <int,int> :: iterator //it->ff it->ss
using namespace std;
/*----------------------Graph Moves----------------*/
//int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1}; int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction
/*------------------------------------------------*/
/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
const int MAXN =1.5e7 + 10; // MAXN=1.5 * 10^7 +10
const double eps = (double)1e-8; // eps = 10^-8
const double PI = acos(-1.0);
inline bool eq(double a,double b){ return abs(b - a) < eps; }
inline double getdouble(){
double x;
scanf("%lf",&x);
return x;
}
#define DB getdouble()
inline int getint(){
int x;
scanf("%d", &x);
return x;
}
#define II getint()
inline long long getlonglong(){
long long x;
scanf("%lld", &x);
return x;
}
#define LL getlonglong()
inline unsigned long long getunsignedlonglong(){
unsigned long long x;
scanf("%llu", &x);
return x;
}
#define ULL getunsignedlonglong()
//__________________________________________________________________
struct point{
double x,y;
point(){}
point(double i, double j){
x=i; y=j;
}
point operator - (point b){
point c;
c.x=x-b.x;
c.y=y-b.y;
return c;
}
double operator * (point b){ //dot product
return x*b.x+y*b.y;
}
double operator ^ (point b){ //cross product
return x*b.y-y*b.x;
}
bool operator < (point b){
return (x<b.x || (x==b.x && y<b.y));
}
bool operator == (point b){
return (eq(x,b.x) && eq(y,b.y)); //check line 50 and 52
}
double norm(){
return x*x+y*y;
}
double abs(){
return sqrt(norm()); //value of a vector
}
point rotate(double theta){ //rotate a point by theta radian around origin point
point c;
c.x=cos(theta)*x - sin(theta)*y;
c.y=sin(theta)*x + cos(theta)*y;
return c;
}
point rotate90(){
return point(-y,x);
}
friend ostream& operator << (ostream& os, point p){ // point p; cin>>p;
return os<<"("<<p.x<<","<<p.y<<")";
}
friend istream& operator >> (istream& is, point& a){ //point p; cin>>p; cout<<p<<endl;
return is>>a.x>>a.y;
}
};
int ccw(point a, point b, point c){
b=b-a, c=c-a;
if((b^c) > 0) return +1; // counter clockwise
if((b^c) < 0) return -1; // clockwise
if((b*c) < 0) return +2; // c -- a -- b
if(b.norm() < c.norm()) return -2; // a -- b -- c
return 0; // a -- c -- b
}
double dis(point a, point b){
return sqrt((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y));
}
bool parallel(point a, point b){ // a and b is vector
return abs(a^b)<eps; // eps = 0.00000001
}
bool orthogonal(point a, point b){ // a and b is vector
return abs(a*b)<eps; // eps = 0.00000001
}
bool intersect(point a, point b, point c, point d){ //a,b segment and b,c segment
return (ccw(a,b,c)*ccw(a,b,d)<=0 && ccw(c,d,a)*ccw(c,d,b)<=0);
}
int slope(point a, point b){
if(a.x*b.y==a.y*b.x) return 0; //slope of a is equal b
if(a.x*b.y < a.y*b.x) return 1; // slope of a is less than b
return -1; // slope of a is greater than b;
}
double line_To_Point_Dis(point a, point b, point c, bool isSegment){
double dist = ((b-a)^(c-a)) / sqrt((b-a)*(b-a));
if(isSegment){
if(((b-a)*(c-b)) > 0) return dis(b,c);
if(((a-b)*(c-a)) > 0) return dis(a,c);
}
return abs(dist);
}
/*-----------------------------Macro End--------------------------------*/
int main(){
}