이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |