/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 2ms 532.0 KiB

Code

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool is_permutation(vector<int>& vec,long long n){
     vector<int> frq(n+1,0);
     for(auto it: vec){
          if(it<1 or it > n){
               return false;
          }
          frq[it]++;
     }
     for(int i=1;i<=n;i++){
          if(frq[i]!=1){
               return false;
          }
     }
     return true;
}

int main() {
    long long t;cin >> t;
    while(t--){
     long long n;cin>>n;
     vector<int> a(n);
     for(int i=0;i<n;i++){
          cin>>a[i];
     }
     if(is_permutation(a,n))cout << "YES\n";
     else cout << "NO\n";    
     }
    
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1055 Array Permutation
Contest
Brain Booster #3
Language
C++17 (G++ 13.2.0)
Submit At
2024-05-06 15:54:49
Judged At
2024-11-11 03:33:41
Judged By
Score
100
Total Time
2ms
Peak Memory
532.0 KiB