-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·72 lines (62 loc) · 1.32 KB
/
Copy pathsol.cpp
File metadata and controls
executable file
·72 lines (62 loc) · 1.32 KB
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
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
bool pairSolvesAllFive(unordered_set<int> &s1, unordered_set<int> &s2)
{
for (int i = 1; i <= 5; ++i)
{
if (s1.find(i) == s1.end() && s2.find(i) == s2.end())
{
return false;
}
}
return true;
}
bool pairCanSolveAllFive(vector<unordered_set<int>> &scores)
{
for (int s1 = 0; s1 < scores.size(); ++s1)
{
for (int s2 = s1 + 1; s2 < scores.size(); ++s2)
{
if (pairSolvesAllFive(scores[s1], scores[s2]))
{
return true;
}
}
}
return false;
}
int main()
{
int T;
cin >> T;
while (T--)
{
int N;
cin >> N;
vector<unordered_set<int>> student_scores;
for (int i = 0; i < N; ++i)
{
unordered_set<int> scores;
int K;
cin >> K;
for (int ii = 0; ii < K; ++ii)
{
int tmp;
cin >> tmp;
scores.insert(tmp);
}
student_scores.push_back(scores);
}
if (pairCanSolveAllFive(student_scores))
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
return 0;
}