#include <bits/stdc++.h>
#include "dango3.h"
using namespace std;
vector<int> trya(vector<int> v, int x) {
vector<int> vv;
for (int w : v) {
if (w != x) {
vv.push_back(w);
}
}
return vv;
}
/*void Print(vector<int> v) {
for (int w : v) cout << w << " ";
cout << '\n';
}
int Query(vector<int> v) {
Print(v);
int k;
cin >> k;
return k;
}
void Answer(vector<int> v) {
Print(v);
}
void Solve(int n, int m);
int main() {
int n = 4, m = 4;
Solve(n, m);
}*/
map<int, vector<int>> mm;
void Solve(int n, int m) {
vector<int> v;
vector<vector<int>> res;
for (int i = 1; i <= n * m; i++) {
v.push_back(i);
}
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
shuffle(v.begin(), v.end(), default_random_engine(seed));
int h = 0, l = n;
while (v.size() > n) {
mm[l] = v;
int g = Query(trya(v, v[h]));
if (g != 0) {
v = trya(v, v[h]);
l = g;
}
else h++;
}
mm[1] = v;
res.push_back(v);
for (int i = 2; i <= m; i++) {
vector<int> vv = mm[i];
for (int j = 0; j < i - 1; j++) {
for (int w : res[j]) {
vv = trya(vv, w);
}
}
int h = 0;
while (vv.size() > n) {
int g = Query(trya(vv, vv[h]));
if (g != 0) {
vv = trya(vv, vv[h]);
}
else h++;
}
res.push_back(vv);
}
for (auto w : res) Answer(w);
}
Compilation message
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:41:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
41 | while (v.size() > n) {
| ~~~~~~~~~^~~
dango3.cpp:60:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
60 | while (vv.size() > n) {
| ~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
580 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
407 ms |
1024 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1030 ms |
1456 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |