/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'int main()':
foo.cc:30:13: error: '__wrap_iter' was not declared in this scope
   30 |             __wrap_iter<int *> doesExistInList = find(list.begin(), list.end(), a[i]);
      |             ^~~~~~~~~~~
foo.cc:30:25: error: expected primary-expression before 'int'
   30 |             __wrap_iter<int *> doesExistInList = find(list.begin(), list.end(), a[i]);
      |                         ^~~
foo.cc:31:17: error: 'doesExistInList' was not declared in this scope
   31 |             if (doesExistInList != list.end()) {
      |                 ^~~~~~~~~~~~~~~

Code

#include <iostream>
#include <vector>

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int t;
    cin >> t;

    while (t--) {
        int n;
        cin >> n;
        bool isPermutation = true;
        int a[n];
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        vector<int> list;
        for (int i = 0; i < n; ++i) {
            if (a[i] > n) {
                cout << "NO" << endl;
                isPermutation = false;
            }
            __wrap_iter<int *> doesExistInList = find(list.begin(), list.end(), a[i]);
            if (doesExistInList != list.end()) {
                cout << "NO" << endl;
                isPermutation = false;
            } else {
                list.push_back(a[i]);
            }
        }
        if (isPermutation) {
            cout << "YES" << endl;
        }
    }


    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 15:14:59
Judged At
2024-11-11 03:34:52
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes