Submission #886698

#TimeUsernameProblemLanguageResultExecution timeMemory
886698vjudge1Doktor (COCI17_doktor)C++17
0 / 100
2 ms348 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; }

Compilation message (stderr)

doktor.cpp: In function 'int main()':
doktor.cpp:50:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |         freopen("in.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
doktor.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen("out.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...