Submission #876272

# Submission time Handle Problem Language Result Execution time Memory
876272 2023-11-21T13:31:18 Z danikoynov Super Dango Maker (JOI22_dango3) C++17
100 / 100
159 ms 832 KB
#include "dango3.h"

#include <bits/stdc++.h>

using namespace std;


int get_query(vector < int > lf, vector < int > rf)
{
    for (int cur : rf)
        lf.push_back(cur);
    return Query(lf);
}

mt19937 rng;
int n, m;
void random_shuffle(vector < int > &d)
{
    for (int i = 0; i < d.size(); i ++)
    {
        swap(d[i], d[rng() % d.size()]);
    }
}
void sub_solve(vector < int > &d)
{
    for (int step = 0; step < m; step ++)
    {
        random_shuffle(d);
        int lf = 0, rf = (int)(d.size()) - 1;

        while(lf <= rf)
        {
            int mf = (lf + rf) / 2;
            vector < int > ch;
            for (int i = 0; i < mf; i ++)
                ch.push_back(d[i]);
            if (Query(ch) > 0)
                rf = mf - 1;
            else
                lf = mf + 1;
        }

        vector < int > secure, trash;
        vector < int > cur;
        for (int i = 0; i <= rf; i ++)
            cur.push_back(d[i]);
        while(cur.size() > 0)
        {
            int bk = cur.back();
            cur.pop_back();
            if (get_query(cur, secure) > 0)
                trash.push_back(bk);
            else
                secure.push_back(bk);
        }

        Answer(secure);
        vector < int > new_vec;
        for (int el : trash)
            new_vec.push_back(el);
        for (int i = rf + 1; i < d.size(); i ++)
            new_vec.push_back(d[i]);
        d = new_vec;
    }

}
void Solve(int N, int M)
{
    n = N;
    m = M;
    vector < int > d;
    for (int i = 1; i <= N * M; i ++)
        d.push_back(i);

    sub_solve(d);
}

Compilation message

dango3.cpp: In function 'void random_shuffle(std::vector<int>&)':
dango3.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < d.size(); i ++)
      |                     ~~^~~~~~~~~~
dango3.cpp: In function 'void sub_solve(std::vector<int>&)':
dango3.cpp:61:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (int i = rf + 1; i < d.size(); i ++)
      |                              ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 600 KB Output is correct
2 Correct 31 ms 604 KB Output is correct
3 Correct 30 ms 632 KB Output is correct
4 Correct 25 ms 604 KB Output is correct
5 Correct 27 ms 656 KB Output is correct
6 Correct 26 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 732 KB Output is correct
2 Correct 115 ms 832 KB Output is correct
3 Correct 117 ms 772 KB Output is correct
4 Correct 113 ms 604 KB Output is correct
5 Correct 159 ms 604 KB Output is correct
6 Correct 107 ms 780 KB Output is correct