Submission #473649

# Submission time Handle Problem Language Result Execution time Memory
473649 2021-09-15T19:15:59 Z MamdouhN Doktor (COCI17_doktor) C++17
80 / 100
1000 ms 59432 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

map<pair<int,int>,int>idk;
map<pair<int,int>,pair<int,int>>k;

main()
{
    int n;
    cin>>n;
    int ar[n];
    int doingnothing=0;
    vector<int>lol;
    lol.push_back(0);
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        if(ar[i]==i+1)doingnothing++;
        int x = min(ar[i]-1,i);
        int y = max(ar[i]-1,i);
        int dist = min(x - 0 , n - y-1);
        //cout<<x-dist<<" "<<y+dist<<endl;
        idk[{ x-dist , y+dist }]++;
        if(y>k[{ x-dist , y+dist }].second)k[{ x-dist , y+dist }] = {x,y};
        lol.push_back(doingnothing);
    }
    int x = 0;
    pair<int,int>ans;
    for(auto v:idk)
    {
        int st = k[{v.first.first,v.first.second}].first;
        int en = k[{v.first.first,v.first.second}].second;
        int z = lol[en+1] - lol[st];
        if(v.second-z> x)
        {
            x = v.second;
            ans = {st,en};
        }
    }
    cout<<ar[ans.first]<<" "<<ar[ans.second]<<endl;
}

Compilation message

doktor.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 844 KB Output is correct
2 Correct 3 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1484 KB Output is correct
2 Correct 119 ms 7196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 134 ms 11532 KB Output is correct
2 Correct 34 ms 2684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 59432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 498 ms 35112 KB Output isn't correct
2 Halted 0 ms 0 KB -