Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- #define ppb pop_back
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<ll int> a(n);
- for(auto &e: a)
- cin>>e;
- int pos1, pos2, posn;
- for(int i=0; i<n; i++)
- {
- if(a[i]==1) pos1 = i;
- if(a[i]==2) pos2 = i;
- if(a[i]==n) posn = i;
- }
- if((pos1<posn && posn<pos2) || (pos1>posn && posn>pos2))
- cout<<pos1+1<<" "<<pos1+1<<"\n";
- else if((pos1<pos2 && pos2<posn) || (pos1>pos2 && pos2>posn))
- cout<<pos2+1<<" "<<posn+1<<"\n";
- else
- cout<<pos1+1<<" "<<posn+1<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment