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 <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <set>
#include <vector>
#include "grader.h"
const int MAXN = 256;
std::set<int> candidates[MAXN + 1];
std::set<int> available, cavailable;
std::vector<int> q;
int order_of_key(std::set<int> st, int poz){
auto it = st.begin();
while(poz > 0){
it++;
poz--;
}
return *it;
}
void solve(int n){
srand(time(0));
int i, j;
for( i = 1; i <= n; i++ ){
available.insert(i);
for( j = 1; j <= n; j++ )
candidates[i].insert(j);
}
for( i = 1; i <= n; i++ ){
while(candidates[i].size() > 1){
q[i] = order_of_key(candidates[i], rand() % candidates[i].size() + 1);
available.erase(q[i]);
cavailable = available;
for( j = i + 1; j <= n; j++ ){
q[j] = order_of_key(available, rand() % available.size() + 1);
available.erase(q[j]);
}
available = cavailable;
if( query(q) == i - 1 ){
for( j = i; j <= n; j++ ){
if(candidates[j].find(q[j]) != candidates[j].end())
candidates[j].erase(q[j]);
}
}
q[i] = *candidates[i].begin();
for( j = i + 1; j <= n; j++ )
if(candidates[j].find(q[i]) != candidates[j].end())
candidates[j].erase(q[i]);
}
}
query(q);
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... |