Submission #690528

# Submission time Handle Problem Language Result Execution time Memory
690528 2023-01-30T09:13:32 Z alexdd CONSUL (info1cup19_consul) C++17
100 / 100
26 ms 348 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;

unordered_map<int,int> fr1;
unordered_map<int,bool> bl1;
unordered_map<int,int> fr2;
unordered_map<int,bool> bl2;
int maxq;
int cntq;
int actual_kth(int k)
{
    if(bl1[k]==0)
    {
        fr1[k]=kth(k);
        bl1[k]=1;
        cntq++;
    }
    return fr1[k];
}
int actual_cnt(int x)
{
    if(bl2[x]==0)
    {
        fr2[x]=cnt(x);
        bl2[x]=1;
        cntq++;
    }
    return fr2[x];
}

void solve(int n)
{
    cntq=0;
    fr1.clear();
    bl1.clear();
    fr2.clear();
    bl2.clear();
    maxq=min(60,n);

    mt19937 rnd(82396293);

    while(cntq+2<=maxq)
    {
        int x = 1 + (rnd())%n;
        if(bl1[x]==0)
        {
            int care = actual_kth(x);
            if(actual_cnt(care) > n/3)
            {
                say_answer(care);
                return;
            }
        }
    }
    say_answer(-1);
    return;
}

# Verdict Execution time Memory Grader output
1 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 208 KB Output is correct
2 Correct 12 ms 300 KB Output is correct
3 Correct 8 ms 292 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 22 ms 208 KB Output is correct
6 Correct 10 ms 348 KB Output is correct
7 Correct 26 ms 208 KB Output is correct
8 Correct 13 ms 344 KB Output is correct
9 Correct 22 ms 292 KB Output is correct
10 Correct 22 ms 208 KB Output is correct
11 Correct 18 ms 208 KB Output is correct
12 Correct 17 ms 208 KB Output is correct
13 Correct 21 ms 296 KB Output is correct
14 Correct 20 ms 208 KB Output is correct