/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 3ms 864.0 KiB
#3 Accepted 1ms 576.0 KiB
#4 Wrong Answer 2ms 532.0 KiB
#5 Wrong Answer 3ms 788.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'
#define rev_str(str) reverse(str.begin(),str.end());
#define all(x) x.begin(), x.end()
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define print(v) for(auto e:v) cout<<e<<" "; cout<<endl;

void solve() {
    int n; cin >> n;
    vector<int>p(n),q,s,check,jjk;
    for(int i = 0; i <n ; i++) {
        cin >> p[i];
    }
    ll idx = 0;
    bool ok = false;
    for(int i = 1; i < n ; i++) {
        if(p[i] > p[i-1] && !ok){
            idx = i;
        }
        else{
            ok = true;
            q.push_back(p[i]);
        }
    }
    check = q;
    rev_str(check);
    if(!check.empty()){
       if(is_sorted(all(check))) {
          cout << "YES" << endl;return;
        }
    }
    ok = false;
    ll index = 0;
    for(int i = 1; i < n; i++) {
        if(p[i] < p[i-1] && !ok) {
            index = i;
        }
        else{
            ok = true;
            s.push_back(p[i]);
            //cout << p[i] <<' ';
        }
    }
    if(!s.empty()){
        if(is_sorted(all(s))) {
           cout << "YES" << endl;return;
        }
    }

    cout <<"NO" << endl;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1; cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1229 Array of Beauty
Contest
LUCC Presents Kick & Code Intra LU Programming Contest
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 07:06:50
Judged At
2025-09-01 07:06:50
Judged By
Score
30
Total Time
3ms
Peak Memory
864.0 KiB