Submission #886699

#TimeUsernameProblemLanguageResultExecution timeMemory
886699vjudge1Doktor (COCI17_doktor)C++17
30 / 100
1097 ms2140 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...