forked from Autoratch/Thailand-Olympiad-in-Informatics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
toi14_blockchain.cpp
49 lines (43 loc) · 929 Bytes
/
toi14_blockchain.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
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7
int m,n;
map<vector<pair<int,int> >,int> s;
vector<vector<pair<int,int> > > a;
vector<pair<int,int> > b;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> m >> n;
a.resize(m);
for(int i = 0;i < m;i++)
{
int sz;
cin >> sz;
for(int j = 1;j < sz;j++)
{
int x,y;
cin >> x >> y;
x--; y--;
a[i].push_back({min(x,y),max(x,y)});
}
sort(a[i].begin(),a[i].end());
s[a[i]]++;
}
for(int i = 0;i < n;i++)
{
int sz;
cin >> sz;
b.resize(0);
for(int j = 1;j < sz;j++)
{
int x,y;
cin >> x >> y;
x--; y--;
b.push_back({min(x,y),max(x,y)});
}
sort(b.begin(),b.end());
cout << s[b] << endl;
}
}