/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 2ms 320.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

const int MAX = 1e5 + 7, MOD = 1e9 + 7;
void solve() {
  int n; cin >> n;
  std::vector<int> v(n), v2(n);
  for (int i = 1; i <= n; i++)
    v[i - 1] = i;

  for (int i = 1; i <= n; i++) {
    cin >> v2[i - 1];
  }
  if (is_permutation(v.begin(), v.end(), v2.begin()) == true) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int t = 1;
  cin >> t;
  for (int tc = 1; tc <= t; tc++) {
    //cout<<"case "<<tc<<": ";
    solve();
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1055 Array Permutation
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 16:06:30
Judged At
2024-11-11 03:33:26
Judged By
Score
100
Total Time
2ms
Peak Memory
320.0 KiB