/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'int main()':
foo.cc:67:2: error: expected '}' at end of input
   67 | }
      |  ^
foo.cc:27:12: note: to match this '{'
   27 | int main() {
      |            ^

Code

#include <bits/stdc++.h>

using namespace std;

int n;
vector<int> a;
deque<int> temp1, temp2;
bool solve(int pos){
int l = pos, r = pos;
while (!temp2.empty()){
int first = temp2.front();
int second = temp2.back();
if (l > 0 && (a[l - 1] == first or a[l - 1] == second)){
l--;
if (a[l] == first) temp2.pop_front();
else temp2.pop_back();
} else if (r + 1 < n && (a[r + 1] == first or a[r + 1] == second)){
r++;
if (a[r] == first) temp2.pop_front();
else temp2.pop_back();
} else {
return false;
}
}
return true;
}
int main() {
int t;
cin >> t;
while (t--) {
bool ok = false;
cin >> n;
vector<int> A(n);
for (int i = 0; i < n; i++) {
cin >> A[i];
temp1.push_back(A[i]);
}
temp2 = temp1;
a = A;
sort(a.begin(), a.end());
for (int i = 0; i < n; i++) {
if (a[i] == temp2.front()) {
temp2.pop_front();
ok = solve(i);
break;
}

}
int y=0;
for(int i=0;i<n;i++){
  for(int j=0;j<n-i-1;j++){
    y++;
  }
}
while (!temp2.empty()) temp2.pop_back();
temp2 = temp1;
for (int i = 0; i < n; i++) {
if (a[i] == temp2.back()) {
temp2.pop_back();
ok = ok or solve(i);
break;
}
}
cout << (ok ? "YES " : "NO") << endl;
while (!temp2.empty()) temp2.pop_back();
while (!temp1.empty()) temp1.pop_back();
}

Information

Submit By
Type
Submission
Problem
P1229 Array of Beauty
Contest
Testing - Intra LU Programming contest 25
Language
C++17 (G++ 13.2.0)
Submit At
2025-08-30 19:16:51
Judged At
2025-08-30 19:16:51
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes