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 <bits/stdc++.h>
#include "dango3.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
//~ #define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vii;
/* __ __ __ */
/* ====== _ /| /| __ _ / | | /| | @ | | | | / /| |\ | / | | @ | / */
/* || |_| |_ / |/ | | | |_ |- | |--| /-| | | \ \ |==| |- /=| | \ | | |--| | |- */
/* || | | |_ / | |__| _| |_ \__ | | / | |__ | __| | | | \ / | | \| \__ | | | | \ */
/* */
void Solve(int N, int M) {
queue<pair<vi, int> > q;
vi a;
for(int i = 1; i <= N*M; i++){
a.pb(i);
}
q.push({a, M});
while(q.empty()){
auto [v, k] = q.front();
q.pop();
if(k <= 1){
Answer(v);
continue;
}else{
int n = v.size();
vector <int> used(n);
for(int i = 0; i < n; i++){
used[i]=1;
vector <int> x;
for(int j = 0; j < n; j++){
if(used[j] == 0)x.pb(v[j]);
}
if(Query(x) < k/2)used[i]=0;
}
vector <int> g1,g2;
for(int i = 0; i < n; i++){
if(used[i]==0)g1.push_back(v[i]);
else g2.push_back(v[i]);
}
q.push({g1,k/2});
if(k%2==1)q.push({g2,k/2+1});
else q.push({g2,k/2});
}
}
return;
}
# | 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... |