Submission #574576

# Submission time Handle Problem Language Result Execution time Memory
574576 2022-06-08T21:11:16 Z erekle Super Dango Maker (JOI22_dango3) C++17
100 / 100
3769 ms 812 KB
#include "dango3.h"

#include <vector>

using namespace std;

bool allDistinct(vector<int> &v, int N, int M) {
    vector<int> u; // v must be in increasing order
    for (int i = 1, j = 0; i <= N * M; ++i) {
        if (j < v.size() && v[j] == i) j++;
        else u.push_back(i);
    }
    return Query(u) == M - 1;
}

void Solve(int N, int M) {
    vector<vector<int>> pile(M);
    for (int i = 1; i <= N * M; ++i) {
        int left = -1, right = M - 1;
        while (left + 1 < right) {
            int mid = (left + right) / 2;
            pile[mid].push_back(i);
            if (allDistinct(pile[mid], N, M)) right = mid;
            else left = mid;
            pile[mid].pop_back();
        }
        pile[right].push_back(i);
    }
    for (vector<int> &p : pile) Answer(p);
}

Compilation message

dango3.cpp: In function 'bool allDistinct(std::vector<int>&, int, int)':
dango3.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |         if (j < v.size() && v[j] == i) j++;
      |             ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 340 KB Output is correct
2 Correct 28 ms 364 KB Output is correct
3 Correct 29 ms 468 KB Output is correct
4 Correct 30 ms 340 KB Output is correct
5 Correct 29 ms 340 KB Output is correct
6 Correct 28 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 951 ms 568 KB Output is correct
2 Correct 939 ms 556 KB Output is correct
3 Correct 940 ms 488 KB Output is correct
4 Correct 946 ms 676 KB Output is correct
5 Correct 923 ms 572 KB Output is correct
6 Correct 931 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3769 ms 812 KB Output is correct
2 Correct 3744 ms 700 KB Output is correct
3 Correct 3697 ms 768 KB Output is correct
4 Correct 3696 ms 600 KB Output is correct
5 Correct 3698 ms 808 KB Output is correct
6 Correct 3718 ms 792 KB Output is correct