답안 #894622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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);
      |                ~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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