-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ceiling Function.cpp
80 lines (71 loc) · 1.4 KB
/
Ceiling Function.cpp
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
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(vec) vec.begin(),vec.end()
struct node{
ll val;
ll left,right;
};
node node_tree[257];
ll ind=0;
void insert_(ll &a,ll val)
{
if(a==-1)
{
node_tree[ind].val=val;
node_tree[ind].left=-1;
node_tree[ind].right=-1;
a=ind;
ind++;
return;
}
if(val<node_tree[a].val)
insert_(node_tree[a].left,val);
else
insert_(node_tree[a].right,val);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// cout.tie(NULL);
//x++;
ll n,t,a,b,m,ans=0,q,i,j,k,l;
// long long k=0;
cin>>n>>k;
set<string>tree;
for(i=0;i<n;i++)
{
ind=0;
ll source=-1;
for(j=0;j<k;j++)
{
ll value;
cin>>value;
insert_(source,value);
}
string tree1;
queue<ll>qs;
qs.push(source);
while(!qs.empty())
{
ll u=qs.front();
qs.pop();
if(node_tree[u].left!=-1)
{
tree1+='1';
qs.push(node_tree[u].left);
}
else
tree1+='0';
if(node_tree[u].right!=-1)
{
tree1+='1';
qs.push(node_tree[u].right);
}
else
tree1+='0';
}
tree.insert(tree1);
}
cout<<tree.size()<<'\n';
}