Submission #894622

# Submission time Handle Problem Language Result Execution time Memory
894622 2023-12-28T14:34:14 Z boris_mihov Super Dango Maker (JOI22_dango3) C++17
100 / 100
349 ms 1208 KB
#include "dango3.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>

int n, m;
void rec(std::vector <int> elements, int count)
{
    if (count == 1)
    {
        assert(elements.size() == n);
        Answer(elements);
        return;
    }

    std::vector <int> left = elements, right;
    for (int i = left.size() - 1 ; i >= 0 ; --i)
    {
        right.push_back(left[i]);
        left.erase(left.begin() + i);
        int res = Query(left);  
        if (res < count / 2)
        {
            left.push_back(right.back());
            right.pop_back();
        }
    }

    rec(left, count / 2);
    rec(right, count / 2 + count % 2);
}

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

    rec(elements, m);
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from dango3.cpp:5:
dango3.cpp: In function 'void rec(std::vector<int>, int)':
dango3.cpp:13:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |         assert(elements.size() == n);
      |                ~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 640 KB Output is correct
2 Correct 48 ms 604 KB Output is correct
3 Correct 66 ms 596 KB Output is correct
4 Correct 69 ms 596 KB Output is correct
5 Correct 51 ms 860 KB Output is correct
6 Correct 47 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 186 ms 600 KB Output is correct
2 Correct 349 ms 796 KB Output is correct
3 Correct 260 ms 600 KB Output is correct
4 Correct 264 ms 696 KB Output is correct
5 Correct 187 ms 1208 KB Output is correct
6 Correct 216 ms 852 KB Output is correct