-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHEGLOVE.cpp
51 lines (50 loc) · 1.05 KB
/
CHEGLOVE.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
#include <iostream>
using namespace std;
int main()
{
long long int t , n , i , front = 1 , back = 1 , j ;
int *l , *g , *g1 ;
cin>>t ;
while(t--)
{
cin>>n ;
l = new int[n] ;
g = new int[n] ;
g1 = new int[n] ;
front = 0 ;
back = 0 ;
for(i=0;i<n;i++)
{
cin>>l[i] ;
}
for(i=0;i<n;i++)
{
cin>>g[i] ;
}
for(i = 0 , j = (n-1) ; i < n , j >= 0 ; i++, j--)
{
g1[j] = g[i] ;
}
for(i=0;i<n;i++)
{
if(l[i]<=g1[i])
back++ ;
else break ;
}
for(i=0;i<n;i++)
{
if(l[i]<=g[i])
front++ ;
else break ;
}
//cout<<"back = "<<back<<" front = "<<front<<endl ;
//cout<<"back + front = "<<back+front<<" == "<<n<<endl ;
if((front*back)==(n*n)) cout<<"both"<<endl ;
else if(front==n) cout<<"front"<<endl ;
else if(back==n) cout<<"back"<<endl ;
else cout<<"none"<<endl ;
front = 0 ;
back = 0 ;
}
return 0;
}