Submission #951821

# Submission time Handle Problem Language Result Execution time Memory
951821 2024-03-22T17:39:25 Z EJIC_B_KEDAX Super Dango Maker (JOI22_dango3) C++17
100 / 100
101 ms 792 KB
#include <bits/stdc++.h>
#include "dango3.h"

using ll = long long;

using namespace std;

mt19937_64 mt(chrono::high_resolution_clock::now().time_since_epoch().count());

void Solve(int n, int m) {
    vector<int> have(n * m);
    for (int i = 0; i < n * m; i++) {
        have[i] = i + 1;
    }
    for (int _ = 0; _ < m; _++) {
        shuffle(have.begin(), have.end(), mt);
        vector<int> nw;
        int l = n - 2, r = (int)have.size() - 1;
        while (r - l > 1) {
            int mid = (r + l) / 2;
            nw.clear();
            for (int i = 0; i <= mid; i++) {
                nw.push_back(have[i]);
            }
            if (Query(nw)) {
                r = mid;
            } else {
                l = mid;
            }
        }
        nw.clear();
        for (int i = 0; i <= r; i++) {
            nw.push_back(have[i]);
        }
        for (int i = 0; i < nw.size() && nw.size() > n; i++) {
            int tmp = nw[i];
            swap(nw[i], nw.back());
            nw.pop_back();
            if (!Query(nw)) {
                nw.push_back(tmp);
                swap(nw[i], nw.back());
            } else {
                i--;
            }
        }
        Answer(nw);
        unordered_set<int> st;
        vector<int> have2;
        for (int i : nw) {
            st.insert(i);
        }
        for (int i : have) {
            if (st.find(i) == st.end()) {
                have2.push_back(i);
            }
        }
        swap(have, have2);
    }
}

Compilation message

dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int i = 0; i < nw.size() && nw.size() > n; i++) {
      |                         ~~^~~~~~~~~~~
dango3.cpp:35:52: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |         for (int i = 0; i < nw.size() && nw.size() > n; i++) {
      |                                          ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 600 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 512 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 604 KB Output is correct
2 Correct 22 ms 604 KB Output is correct
3 Correct 21 ms 604 KB Output is correct
4 Correct 24 ms 648 KB Output is correct
5 Correct 22 ms 604 KB Output is correct
6 Correct 22 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 604 KB Output is correct
2 Correct 101 ms 784 KB Output is correct
3 Correct 99 ms 792 KB Output is correct
4 Correct 91 ms 772 KB Output is correct
5 Correct 93 ms 600 KB Output is correct
6 Correct 94 ms 792 KB Output is correct