A. Jagged Swaps

原题链接

题解

对于 \(n\) 来说,所有数都比他小,所以他一定能到达数组末尾
对于 \(n-1\) 来说,同理
...
所以 1 一定要在开头

code

#include<bits/stdc++.h>
using namespace std;
int a[15];
bool solve()
{
    int n;
    cin>>n;

    for(int i=1;i<=n;i++) cin>>a[i];

    if(a[1]==1) return 1;
    return 0;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        if(solve()) puts("yes");
        else puts("no");
    }
    return 0;
}
posted @ 2024-06-25 18:59  纯粹的  阅读(15)  评论(0)    收藏  举报