-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1709A.cpp
More file actions
74 lines (66 loc) · 1.14 KB
/
1709A.cpp
File metadata and controls
74 lines (66 loc) · 1.14 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
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--)
{
int x, a[3], b, c;
bool flag=0;//4/3=1; 1/3=0
cin>>x; //3
for(int i=0; i<3; i++)
cin>>a[i]; //value: index->value, 0->0, 1->1, 2->2
//x=x;
c=2;
while(c--) //2,1,0
{
if(a[x-1]!=0)
//3
//0 1 2
{
flag=1;
x=a[x-1];
}
else
{
flag=0;
break;
}
}
if(flag==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
/*
4
3
0 1 2
1
0 3 2
2
3 1 0
2
1 3 0
*/