Submission #501620

# Submission time Handle Problem Language Result Execution time Memory
501620 2022-01-04T08:26:54 Z amunduzbaev Monster Game (JOI21_monster) C++17
0 / 100
35 ms 288 KB
#include <bits/stdc++.h>
#include "monster.h"

#ifndef EVAL
#include "grader.cpp"
#endif

using namespace std;
 
bool qq(int a, int b) {
  return Query(b, a);
}
 
vector<int> Solve(int n) {
  /// Initial sort
 
  function<vector<int>(int, int)> mrg = [&] (int l, int r) {
    if (l == r) {
      vector<int> v = {l};
      return v;
    }
    int m = (l + r) / 2;
    vector<int> a = mrg(l, m);
    vector<int> b = mrg(m + 1, r);
    vector<int> c;
    c.reserve(r - l + 1);
    int pa = 0, pb = 0;
    while (pa < (int) a.size() && pb < (int) b.size()) {
      if (qq(a[pa], b[pb])) {
        c.push_back(a[pa++]);
      } else {
        c.push_back(b[pb++]);
      }
    }
    while (pa < (int) a.size()) {
      c.push_back(a[pa++]);
    }
    while (pb < (int) b.size()) {
      c.push_back(b[pb++]);
    }
    return c;
  };
  vector<int> rl;
  vector<int> v = mrg(0, n - 1);
  int last = 0;
  int l = 0;
  while (l < n) {
 
    int r = l;
    while (r < n && !qq(v[r], v[last])) {
      r++;
    }
    assert(r < n);
    last = l;
    for (int j = r; j >= l; j--) {
      rl.push_back(v[j]);
    }
    l = r + 1;
  }
  vector<int> inv(n);
  for (int i = 0; i < n; i++) {
    inv[rl[i]] = i;
  }
  return inv;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 288 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -