Codeforces 1365B. Trouble Sort Solution
Solution in C++: ///**********ALLAH IS ALMIGHTY************/// ///AH Tonmoy ///Department of CSE,23rd batch ///Islamic University,Bangladesh
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,a[1000],b,i,n,j,k;
- cin>>t;
- while(t--)
- {
- cin>>n;
- for(i=0; i<n; i++)
- cin>>a[i];
- cin>>k;
- int c=0;
- for(i=0; i<n-1; i++)
- {
- cin>>b;
- if(k!=b)
- c=1;
- }
- if(c==1||is_sorted(a,a+n))
- cout<<"Yes"<<endl;
- else
- cout<<"No"<<endl;
- }
- }
-
No comments