-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrainbow2.cpp
95 lines (82 loc) · 1.19 KB
/
rainbow2.cpp
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <bits/stdc++.h>
using namespace std;
int main()
{
int test,n;
int arr[1000];
for (int i = 0; i < 200; ++i)
{
arr[i]=0;
}
cin >> test;
while(test--)
{
cin >> n;
int pos=0;
for (int i = 1; i <= n; ++i)
{
cin >> arr[i];
}
int temp[15];
for (int i = 1; i <= 10; ++i)
{
temp[i]=0;
}
for (int i = 1; i <=n ; ++i)
{
temp[arr[i]] = 1;
}
/*for (int i = 1; i <=10; ++i)
{
cout << temp[i] << " " ;
}*/
int flag=0,flag2=0;
for (int i = 1; i <= 10; ++i)
{
if (temp[i] == 0 && i <= 7)
{
flag = flag + 1;
}
else if(temp[i] == 1 && i > 7)
{
flag2 = flag2+1;
}
}
// cout << flag <<" "<< flag2 << endl;
if (flag > 0 || flag2 >0)
{
printf("no\n");
}
else
{ int i=1,k=0,check=0;
while(1)
{
if (arr[i]==arr[n-k])
{
i=i+1;
//printf("chamola\n");
//cout << arr[i]<<arr[n-k]<< endl;
//if(arr[i+1]!=arr[n-k])
k=k+1;
}
else if(arr[i] < arr[n-k])
{
i=i+1;
//printf("hola\n");
}
if(arr[i] > arr[n-k])
{
printf("no\n");
check=1;
break;
}
if(arr[i]==7)
break;
}
if (check==0)
{
printf("yes\n");
}
}
}
}