src2020/4074_comingtree/comingtree.cpp

51 lines
1.3 KiB
C++

#include <cstring>
#include <iostream>
using namespace std;
int main()
{
int n, a[26][26] = { 0 }, many = 0;
string s[26];
cin >> n;
for (int i = 1; i <= n; i++) {
int now;
cin >> now;
for (int j = 1; j <= now; j++) {
string nows;
bool pan = 0;
cin >> nows;
for (int k = 1; k <= many; k++) {
if (s[k] == nows) {
a[k][++a[k][0]] = i;
pan = 1;
}
}
if (pan == 0) {
a[++many][++a[many][0]] = i;
s[many] = nows;
}
}
}
for (int i = 1; i < many; i++) {
for (int k = i + 1; k <= many; k++) {
int yi = i, er = i;
if (a[i][0] < a[k][0]) {
yi = k;
} else {
er = k;
}
int ce = 0;
for (int j = 1; j <= a[yi][0]; j++) {
for (int e = 1; e <= a[er][0]; e++) {
if (a[yi][j] == a[er][e]) {
ce++;
}
}
}
if (ce != 0 && ce != a[yi][0] ) {
cout << "no";
return 0;
}
}
}
cout << "yes";
}