This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int m;
vector<int> done, imsi;
vector<int> type[404];
int query(vector<int> q) {
for(auto x : done) q.push_back(x);
for(auto x : imsi) q.push_back(x);
return Query(q);
}
void find(int u, vector<int> v) {
int s = v.size();
if(s == 1) {
// cout << "add " << v[0] << "\n";
type[u].push_back(v[0]);
return;
}
vector<int> v1 = vector<int>(v.begin(), v.begin()+s/2), v2 = vector<int>(v.begin()+s/2, v.end());
int re = query(v1);
if(re) find(u, v1);
else {
for(auto x : v1) imsi.push_back(x);
}
if(type[u].size() < m && (!re || query(v2))) find(u, v2);
else {
for(auto x : v2) imsi.push_back(x);
}
}
void Solve(int N, int M) {
m = M;
vector<int> v(N*M);
iota(v.begin(), v.end(), 1);
random_device rd;
shuffle(v.begin(), v.end(), mt19937(rd()));
for(int i=0;i<N-1;i++) {
find(i, v);
for(auto x : type[i]) done.push_back(x);
for(auto x : type[i]) v.erase(find(v.begin(), v.end(), x));
imsi.clear();
// for(auto x : v) cout << x << " ";
// cout << i << " " << v.size();
// cout << "DONE------------" << endl;
}
type[N-1] = v;
for(int i=0;i<M;i++) {
vector<int> re;
for(int j=0;j<N;j++) {
re.push_back(type[j][i]);
}
Answer(re);
}
}
Compilation message (stderr)
dango3.cpp: In function 'void find(int, std::vector<int>)':
dango3.cpp:33:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
33 | if(type[u].size() < m && (!re || query(v2))) find(u, v2);
| ~~~~~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |