Submission #1029386

#TimeUsernameProblemLanguageResultExecution timeMemory
1029386SzilSuper Dango Maker (JOI22_dango3)C++17
100 / 100
78 ms600 KiB
#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; ) { if (next(it) != x.end() && x.size() > 2*N) { vector<int> y = x; y.erase(find(y.begin(), y.end(), *it)); y.erase(find(y.begin(), y.end(), *next(it))); if (Query(y) == 1) { it = x.erase(it); it = x.erase(it); } else { vector<int> y = x; y.erase(find(y.begin(), y.end(), *it)); if (Query(y) == 1) { it = x.erase(it); it++; } else { it++; } } } else { 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 (stderr)

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; ) {
      |                                                    ~~~~~~~~~^~~~
dango3.cpp:34:49: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |             if (next(it) != x.end() && x.size() > 2*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:64:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |         assert(x.size() == N);
      |                ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...