-
Notifications
You must be signed in to change notification settings - Fork 10
/
Java_initialize.sublime-snippet
190 lines (187 loc) · 4.03 KB
/
Java_initialize.sublime-snippet
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
190
<snippet>
<content><![CDATA[
import java.util.*;
public class a{
static Scanner sc = new Scanner(System.in);
static class Pair{
Integer x, y;
public Pair(Integer _x, Integer _y){
x = _x;
y = _y;
}
@Override
public String toString(){
return "(" + x + ", " + y + ")";
}
}
static class Tuple3{
Integer x, y, z;
public Tuple3(Integer _x, Integer _y, Integer _z){
x = _x;
y = _y;
z = _z;
}
@Override
public String toString(){
return "(" + x + ", " + y + ", " + z + ")";
}
}
static Integer min(Integer x, Integer y){
return Math.min(x, y);
}
static Integer min3(Integer x, Integer y, Integer z){
return Math.min(Math.min(x, y), z);
}
static Integer max(Integer x, Integer y){
return Math.max(x, y);
}
static Integer max3(Integer x, Integer y, Integer z){
return Math.max(Math.max(x, y), z);
}
static Long min(Long x, Long y){
return Math.min(x, y);
}
static Long min3(Long x, Long y, Long z){
return Math.min(Math.min(x, y), z);
}
static Long max(Long x, Long y){
return Math.max(x, y);
}
static Long max3(Long x, Long y, Long z){
return Math.max(Math.max(x, y), z);
}
static class Tuple4{
Integer x, y, z, w;
public Tuple4(Integer _x, Integer _y, Integer _z, Integer _w){
x = _x;
y = _y;
z = _z;
w = _w;
}
}
static final Integer mod = 1000000007;
static Integer add(Integer x, Integer y){
x += y;
if(x >= mod){
x -= mod;
}
return x;
}
static Integer sub(Integer x, Integer y){
x -= y;
if(x < 0){
x += mod;
}
return x;
}
static Integer mul(Integer x, Integer y){
return (int)((long)(int)x * y % mod);
}
static Integer pow(Integer b, Integer e){
Integer res = 1;
while(e > 0){
if(e % 2 == 1) res = mul(res, b);
b = mul(b, b);
e >>= 1;
}
return res;
}
static Integer inv(Integer b){
return pow(b, mod - 2);
}
static Integer div(Integer x, Integer y){
return mul(x, inv(y));
}
////////////////////////////////////////////////////
static Integer[] dsu;
static void dsu_clear(){
for(Integer i = 0; i < dsu.length; ++ i){
dsu[i] = -1;
}
}
static Integer dsu_root(Integer u){
return dsu[u] >= 0 ? dsu[u] = dsu_root(dsu[u]) : u;
}
static Integer dsu_size(Integer u){
return -dsu[dsu_root(u)];
}
static Boolean dsu_share(Integer u, Integer v){
return dsu_root(u).equals(dsu_root(v));
}
static Boolean dsu_merge(Integer u, Integer v){
u = dsu_root(u);
v = dsu_root(v);
if(u.equals(v)){
return false;
}
if(dsu[u] > dsu[v]){
u ^= v;
v ^= u;
u ^= v;
}
dsu[u] += dsu[v];
dsu[v] = u;
return true;
}
static ArrayList<Integer>[] adj;
static Integer[] size, pv, depth;
static Integer[][] lift;
static Integer jump(Integer u, Integer d){
for(Integer bit = 0; bit < 20; ++ bit){
if((d & 1 << bit) > 0){
u = lift[bit][u];
}
}
return u;
}
static Integer lca(Integer u, Integer v){
if(depth[u] < depth[v]){
u ^= v;
v ^= u;
u ^= v;
}
u = jump(u, depth[u] - depth[v]);
if(u.equals(v)){
return u;
}
for(Integer bit = 19; bit >= 0; -- bit){
if(lift[bit][u] != lift[bit][v]){
u = lift[bit][u];
v = lift[bit][v];
}
}
return lift[0][u];
}
static Integer tree_dist(Integer u, Integer v){
Integer w = lca(u, v);
return depth[u] + depth[v] - 2 * depth[w];
}
static final Integer INF = 1000000000;
static final Long LINF = 1000000000000000000l;
static void dfs(Integer u, Integer p){
if(p.equals(-1)){
depth[u] = 0;
}
for(Integer v: adj[u]){
if(!v.equals(p)){
depth[v] = depth[u] + 1;
dfs(v, u);
}
}
}
static Pair[] dr = new Pair[]{new Pair(1, 0), new Pair(0, 1), new Pair(-1, 0), new Pair(0, -1)};
static char[] drid = new char[]{'D', 'R', 'U', 'L'};
////////////////////////////////////////////////////
@SuppressWarnings("unchecked")
public static void main(String[] args){
$0
}
}
/*
*/
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>initialize</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.java</scope> -->
</snippet>