Code
#include<bits/stdc++.h>
#define ll long long int
#define yes "YES"
#define no "NO"
#define nl "\n"
using namespace std;
void solve()
{
int n;
cin>>n;
vector<int>a(n);
for(int i=0; i<n; i++)
{
cin>>a[i];
}
sort(a.begin(),a.end());
int ans=0;
for(int i=0;i<n;i++){
if(a[i]==i+1)
ans++;
}
if(ans==n)
cout<<yes<<nl;
else
cout<<no<<nl;
//cout<<ans<<nl;
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1055 Array Permutation
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-10 15:20:53
- Judged At
- 2024-11-11 03:30:13
- Judged By
- Score
- 100
- Total Time
- 3ms
- Peak Memory
- 324.0 KiB