-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy paththree doors.cpp
More file actions
80 lines (71 loc) · 1.68 KB
/
three doors.cpp
File metadata and controls
80 lines (71 loc) · 1.68 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
73
74
75
76
77
78
79
80
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n,door1=1,door2=2,door3=3,hand,bk1,bk2,bk3,count=0,a,b;
cin >>n;
int t=0;
while (t<n){
cin>>hand;
cin>>bk1>>bk2>>bk3;
if(hand==door3){
a=bk3;
hand =a;
if(hand ==door2){
b=bk2;
hand =b;
if(hand == door1){
count++;
}
}
if(hand ==door1){
b=bk1;
hand =b;
if(hand == door2){
count++;
}
}
}
else if(hand==door2){
a=bk2;
hand =a;
if(hand ==door1){
b=bk1;
hand =b;
if(hand == door3){
count++;
}
}
if(hand ==door3){
b=bk3;
hand =b;
if(hand == door1){
count++;
}
}
}
else {
a=bk1;
hand =a;
if(hand ==door2){
b=bk2;
hand =b;
if(hand == door3){
count++;
}
}
if(hand ==door3){
b=bk3;
hand =b;
if(hand == door2){
count++;
}
}
}
t+=1;
if(count>0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
count =0;
}
}