Submission #1101186

# Submission time Handle Problem Language Result Execution time Memory
1101186 2024-10-15T17:41:15 Z raduv Mouse (info1cup19_mouse) C++17
0 / 100
1 ms 336 KB
#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
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -