Compile Error
foo.cc: In function 'void solve()': foo.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'? 12 | sort(arr.begin(), arr.end()); | ^~~~ | short
Code
#include<iostream>
#include<vector>
using namespace std;
void solve(){
int n;
cin >> n;
vector<int> arr(n);
for(int i=0; i<n; ++i){
cin >> arr[i];
}
sort(arr.begin(), arr.end());
bool z = true;
for (int i = 0; i < n; ++i) {
if (arr[i] != i + 1) {
z = false;
break;
}
}
if(z){
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
int main(){
int t;
cin>> t;
while(t--){
solve();
}
}
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 15:18:21
- Judged At
- 2024-11-11 03:34:48
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes