-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmosAlgo.sublime-snippet
55 lines (52 loc) · 964 Bytes
/
mosAlgo.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
<snippet>
<content><{
int le = e[0]/sq;
int lf = f[0]/sq;
if(lf!=le)return le<lf;
else return e[1]<f[1];
});
int l,r,ans=0;
l = 0;
r = 1;//[LR)
freq[v[0]]++;
ans = 1;
for(int i = 0;i<q;i++)
{
int L = a[i][0];
int R = a[i][1];
// cout<<L<<" "<<R<<endl;
while(r<=R)
{
int val = v[r++];
if(freq[val]==0)ans++;
freq[val]++;
}
while(r>R+1)
{
int val = v[--r];
if(freq[val]==1)ans--;
freq[val]--;
}
while(l<L)
{
int val = v[l++];
if(freq[val]==1)ans--;
freq[val]--;
}
while(l>L)
{
int val = v[--l];
if(freq[val]==0)ans++;
freq[val]++;
}
an[a[i][2]] = ans;
}
for(int i = 0;i<q;i++)cout<<an[i]<<endl;
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>_mos_algorithm</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>