This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e5+5;
int ar[maxn];
int lk[maxn];
signed main() {
//freopen("a.in", "r", stdin);
//freopen("a.out", "w", stdout);
int N;
cin >> N;
int res = 0;
int a = -1, b = -1;
for(int i = 1; i <= N; i++) { cin >> ar[i]; lk[ar[i]] = i;}
for(int i = 1; i <= N; i++) {
for(int j = i; j <= N; j++) {
reverse(ar+i, ar+j+1);
int cnt = 0;
for(int k = 1; k <= N; k++) if(ar[k] == k) cnt++;
reverse(ar+i, ar+j+1);
if(cnt > res) a = ar[i], b = ar[j], res = cnt;
}
}
cout << a << ' ' << b << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |