Submission #670916

#TimeUsernameProblemLanguageResultExecution timeMemory
670916BidoTeimaDoktor (COCI17_doktor)C++17
0 / 100
3 ms596 KiB
/* ID: BidoTeima LANG: C++11 TASK: */ #include <bits/stdc++.h> using namespace std; using ll = long long; void moo(string filename); void ACPLS(string str = "") { if(str=="NOF")return; if(str.size()) moo(str); else{ #ifndef ONLINE_JUDGE freopen("output.txt", "w", stdout); freopen("input.txt", "r", stdin); #endif } ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void moo(string fileName){ freopen((fileName+".in").c_str(),"r",stdin); freopen((fileName+".out").c_str(),"w",stdout); } #define tc \ int tttttt/*,subtask*/; \ cin >> tttttt/* >> subtask*/; \ while (tttttt--)/*end */ int main() { ACPLS(); int n; cin>>n; vector<pair<int,int>>v[2 * n + 1]; int pos[n+1],a[n + 1]; int ps[n + 1]={0}; for(int i = 1; i <= n; i++){ int x; cin>>x; a[i] = x; pos[x] = i; if(i == x){ ps[i]++; //ans++; } ps[i] += ps[i - 1]; } for(int i = 1; i <= n; i++){ v[i + pos[i]].push_back({min(i, pos[i]), max(i, pos[i])}); //cout<<ps[i]<<'\n'; } int res = 0; pair<int,int>ans={1,1}; for(int i = 1; i <= 2 * n; i++){ sort(v[i].begin(), v[i].end()); for(int j = 0; j < (int)v[i].size(); j++){ // contribution = no of (x,y) inside - no opf fixed points inside if((int)v[i].size() - j - (ps[v[i][j].second] - ps[v[i][j].first - 1]) > res){ res = (int)v[i].size() - j - (ps[v[i][j].second] - ps[v[i][j].first - 1]); ans={v[i][j].first,v[i][j].second}; } //cout<<res<<' '<<v[i][j].first<<' '<<v[i][j].second<<'\n'; } } cout<<a[ans.first]<<' '<<a[ans.second]<<'\n'; }

Compilation message (stderr)

doktor.cpp: In function 'void ACPLS(std::string)':
doktor.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
doktor.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
doktor.cpp: In function 'void moo(std::string)':
doktor.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
doktor.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((fileName+".out").c_str(),"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...