forked from vijay532/CompetitiveSources
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRAINBOWA.cpp
More file actions
67 lines (62 loc) · 1.27 KB
/
RAINBOWA.cpp
File metadata and controls
67 lines (62 loc) · 1.27 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
/*
https://www.codechef.com/AUG17/problems/RAINBOWA/
*/
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
long long t,n,i;
cin>>t;
while(t--)
{
cin>>n;
int a[n];
int b[n];
int c[n];
int flag=1;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n/2;i++)
{
b[i]=a[i];
}
for(i=0;i<n/2;i++)
{
c[i]=a[n-i-1];
}
sort(b,b+(n/2));
sort(c,c+(n/2));
if(a[n/2]==7)
{
for(i=0;i<n/2;i++)
{
if(b[i]==c[i]&&flag==1)
{
flag=1;
//cout<<"yes"<<endl;
}
else
{
flag=0;
}
}
if(flag==1)
{
cout<<"yes"<<endl;
}
else if(flag==0)
{
cout<<"no"<<endl;
}
}
else
{
cout<<"no"<<endl;
}
}
// your code goes here
return 0;
}