diff --git a/1896A Jagged Swaps/1896A.cpp b/1896A Jagged Swaps/1896A.cpp new file mode 100644 index 0000000..ab57f2e --- /dev/null +++ b/1896A Jagged Swaps/1896A.cpp @@ -0,0 +1,106 @@ +#include +using namespace std; + +// Short forms +#define int long long +#define ll long long +#define lld long double +#define ull unsigned long long +#define endl '\n' +#define ff first +#define ss second +#define all(x) x.begin(), x.end() +#define sz(x) (int)(x).size() +#define pb push_back +#define ppb pop_back +#define mp make_pair +#define ins insert + +// STLs +#define PII pair +#define VI vector +#define VVI vector> +#define SI set +#define SC set +#define MII map +#define VLL vector +#define VVL vector> +#define SL set + +// Outputs +#define yes cout<<"YES"< void _print(pair p); +template void _print(vector v);template void _print(set v); +template void _print(map v);template void _print(multiset v); +template void _print(pair p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";} +template void _print(vector v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(set v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(multiset v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";} +template void _print(map v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void solve() +{ + int n; + cin>>n; + VI v(n); + for(int i=0; i>v[i]; + bool flag=1; + while(flag) + { + flag=0; + for(int i=1; iv[i-1] && v[i]>v[i+1]) + { + flag = 1; + swap(v[i],v[i+1]); + } + } + } + if(is_sorted(all(v))) + yes; + else + no; +} + +int32_t main() +{ + FAST_IO; + int TC = 1; + cin >> TC; + while (TC--) solve(); +} \ No newline at end of file