Submission #780893

# Submission time Handle Problem Language Result Execution time Memory
780893 2023-07-12T14:24:13 Z Andrey CONSUL (info1cup19_consul) C++14
100 / 100
25 ms 296 KB
#include "grader.h"
#include<bits/stdc++.h>
using namespace std;

void solve(int n)
{
    srand(time(NULL));
    vector<int> bruh(0);
    for(int i = 0; i < n; i++) {
        bruh.push_back(i+1);
    }
    int q,a,br,b;
    if(n <= 50) {
        q = 25;
    }
    else {
        q = 30;
    }
    for(int i = 0; i < min(n,q); i++) {
        a = rand()%(n-i);
        b = kth(bruh[a]);
        br = cnt(b);
        if(br > n/3) {
            say_answer(b);
            return;
        }
        else {
            for(int j = a; j < bruh.size()-1; j++) {
                swap(bruh[j],bruh[j+1]);
            }
            bruh.pop_back();
        }
    }
    say_answer(-1);
}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:28:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for(int j = a; j < bruh.size()-1; j++) {
      |                            ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 208 KB Output is correct
2 Correct 25 ms 208 KB Output is correct
3 Correct 4 ms 288 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 20 ms 272 KB Output is correct
6 Correct 23 ms 268 KB Output is correct
7 Correct 17 ms 256 KB Output is correct
8 Correct 25 ms 208 KB Output is correct
9 Correct 20 ms 208 KB Output is correct
10 Correct 17 ms 208 KB Output is correct
11 Correct 23 ms 208 KB Output is correct
12 Correct 24 ms 296 KB Output is correct
13 Correct 19 ms 256 KB Output is correct
14 Correct 13 ms 288 KB Output is correct