#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
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 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 |
344 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
16 ms |
348 KB |
Output is correct |
2 |
Correct |
17 ms |
564 KB |
Output is correct |
3 |
Correct |
15 ms |
348 KB |
Output is correct |
4 |
Correct |
16 ms |
344 KB |
Output is correct |
5 |
Correct |
18 ms |
560 KB |
Output is correct |
6 |
Correct |
18 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
348 KB |
Output is correct |
2 |
Correct |
78 ms |
348 KB |
Output is correct |
3 |
Correct |
73 ms |
600 KB |
Output is correct |
4 |
Correct |
67 ms |
344 KB |
Output is correct |
5 |
Correct |
71 ms |
348 KB |
Output is correct |
6 |
Correct |
76 ms |
348 KB |
Output is correct |