Submission #924727

#TimeUsernameProblemLanguageResultExecution timeMemory
924727boris_mihovMonster Game (JOI21_monster)C++17
0 / 100
70 ms712 KiB
#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 (stderr)

monster.cpp: In function 'void rec(std::vector<int>&)':
monster.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 1 ; i < v.size() ; ++i)
      |                      ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...