# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
924727 | 2024-02-09T14:58:00 Z | boris_mihov | Monster Game (JOI21_monster) | C++17 | 70 ms | 712 KB |
#include "monster.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> #include <random> typedef long long llong; const int MAXN = 1000 + 10; const int INF = 1e9; std::mt19937 rng(69420); void rec(std::vector <int> &v) { if (v.size() <= 1) { return; } if (v.size() == 2) { if (!Query(v[0], v[1])) std::swap(v[0], v[1]); return; } int idx = rng() % v.size(); std::swap(v[0], v[idx]); int pivot = v[0]; std::vector <int> left, right; for (int i = 1 ; i < v.size() ; ++i) { if (Query(pivot, v[i])) left.push_back(v[i]); else right.push_back(v[i]); } left.push_back(pivot); rec(left); rec(right); v.clear(); for (const int &i : left) { v.push_back(i); } for (const int &i : right) { v.push_back(i); } } std::vector <int> res; std::vector <int> Solve(int n) { std::vector <int> v(n); std::iota(v.begin(), v.end(), 0); rec(v); res.resize(n); for (int i = 0 ; i < n ; ++i) { res[v[i]] = i; } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Wrong Answer [3] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Wrong Answer [3] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 70 ms | 712 KB | Wrong Answer [3] |
2 | Halted | 0 ms | 0 KB | - |