Submission #1029385

# Submission time Handle Problem Language Result Execution time Memory
1029385 2024-07-20T20:01:17 Z Szil Super Dango Maker (JOI22_dango3) C++17
100 / 100
108 ms 604 KB
#include "dango3.h"

#include <bits/stdc++.h>

using namespace std;

namespace {

mt19937 rng(42);

}

/*
4 4                                  
1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
*/

void Solve(int N, int M) {
    vector<int> v(N*M);
    iota(v.begin(), v.end(), 1);
    while (!v.empty()) {
        shuffle(v.begin(), v.end(), rng);
        int lo = 0, hi = v.size() - 1;
        while (lo < hi) {
            int mid = (lo + hi) / 2;
            if (Query(vector<int>(v.begin(), v.begin()+mid+1)) == 0) {
                lo = mid + 1;
            } else {
                hi = mid;
            }
        }
        vector<int> x(v.begin(), v.begin()+lo+1);
        for (auto it = x.begin(); it != x.end() && x.size() != N; ) {
            vector<int> y = x;
            y.erase(find(y.begin(), y.end(), *it));
            if (Query(y) == 1) {
                it = x.erase(it);
            } else {
                it++;
            }        }
        for (int a : x) {
            v.erase(find(v.begin(), v.end(), a));
        }
        assert(x.size() == N);
        Answer(x);
    }
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:33:61: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         for (auto it = x.begin(); it != x.end() && x.size() != N; ) {
      |                                                    ~~~~~~~~~^~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dango3.cpp:3:
dango3.cpp:44:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |         assert(x.size() == N);
      |                ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 348 KB Output is correct
2 Correct 25 ms 348 KB Output is correct
3 Correct 21 ms 552 KB Output is correct
4 Correct 25 ms 348 KB Output is correct
5 Correct 24 ms 348 KB Output is correct
6 Correct 21 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 604 KB Output is correct
2 Correct 105 ms 604 KB Output is correct
3 Correct 105 ms 604 KB Output is correct
4 Correct 92 ms 604 KB Output is correct
5 Correct 108 ms 604 KB Output is correct
6 Correct 89 ms 604 KB Output is correct