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());
if(query(v1)) find(u, v1);
if(query(v2)) find(u, v2);
}
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++) {
// cout << i << " " << v.size() << endl;
int l = 1, r = (int)v.size()-1;
while(l <= r) {
int mid = (l+r) >> 1;
auto re = query(vector<int>(v.begin(), v.begin()+mid+1));
if(re) r = mid-1;
else l = mid+1;
}
imsi = vector<int>(v.begin(), v.begin()+l);
find(i, vector<int>(v.begin()+l, v.end()));
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 << "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);
}
}
# | 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... |