# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886698 | vjudge1 | Doktor (COCI17_doktor) | C++17 | 2 ms | 348 KiB |
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;
using i64 = long long;
//#define ONLINE_JUDGE
void solve() {
int n;
cin >> n;
vector <int> a(n +1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
auto rev = [&](int l, int r) -> void {
while(l <= r) {
swap(a[l], a[r]);
r--;
l++;
}
return;
};
array <int, 3> ans = {-1, 0, 0};
for(int l = 1; l <= n; l++) {
for(int r = l; r <= n; r++) {
rev(l, r);
int cnt = 0;
for(int i = 1; i <= n; i++) {
cnt += (a[i] == i);
}
rev(l, r);
if(cnt > ans[0]) {
ans = {cnt, a[l], a[r]};
}
}
}
cout << ans[1] << " " << ans[2];
return;
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int t = 1; //cin >> t;
for(int i = 1; i <= t; i++) {
solve();
}
return 0;
}
Compilation message (stderr)
# | 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... |