-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABC_232_C.cpp
More file actions
53 lines (46 loc) · 1.12 KB
/
Copy pathABC_232_C.cpp
File metadata and controls
53 lines (46 loc) · 1.12 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
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int> one_case;
int N;
int M;
cin >> N;
cin >> M;
vector<pair<int, int>> tak;
for(int i = 0; i < N; i++){
cin >> tak.at(i).first;
cin >> tak.at(i).second;
}
vector<pair<int, int>> aok;
for(int i = 0; i < N; i++){
cin >> aok.at(i).first;
cin >> aok.at(i).second;
}
for(int i = 0; i < N + 1; i++){
one_case.emplace_back(i + 1);
}
string ans;
do{
//条件
//任意の整数に対して以下が成り立つ
//高橋のi,jが紐で繋がれている場合、青木のPi,Pjは紐で繋がれている。
//条件を満たす数列があればYes、なければNo
ans = "Yes";
for(int i = 0; i < N - 1; i++){
for(int j = 0; j < N; j++){
for(int k = 0; k < N; k ++){
if(tak.at(k).first != (one_case.at(i + 1))){
if(tak.at(k).second != one_case.at(j + 1)){
ans = "No";
}
}
}
}
}
if(ans =="Yes"){
break;
}
} while(next_permutation(one_case.begin(), one_case.end()));
cout << ans << endl;
return 0;
}