Submission #247192

#TimeUsernameProblemLanguageResultExecution timeMemory
247192shenxyWine Tasting (FXCUP4_wine)C++17
43 / 100
12 ms1052 KiB
#include "bartender.h" #include <algorithm> #include <vector> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> os; vector<int> BlendWines(int K, vector<int> R){ vector<int> ans(R.size(), 0); __int128_t x = 0, fac[R.size()]; os a; for (int i = 1; i <= R.size(); ++i) a.insert(i); fac[0] = 1; for (int i = 1; i < R.size(); ++i) fac[i] = i * fac[i - 1]; for (int i = 0; i < R.size(); ++i) { x = x + a.order_of_key(R[i]) * fac[R.size() - i - 1]; a.erase(R[i]); } for (int i = 0; i < R.size(); ++i) { ans[i] = x % 13 + 1; x /= 13; } return ans; }
#include "taster.h" #include <algorithm> #include <vector> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> os; vector<int> SortWines(int K, vector<int> A) { vector<int> ans(A.size(), 0); __int128_t x = 0, fac[A.size()]; for (int i = A.size() - 1; i >= 0; --i) x = x * 13 + A[i] - 1; os a; for (int i = 1; i <= A.size(); ++i) a.insert(i); fac[0] = 1; for (int i = 1; i < A.size(); ++i) fac[i] = i * fac[i - 1]; for (int i = 0; i < A.size(); ++i) { ans[i] = *a.find_by_order(x / fac[A.size() - 1 - i]); x %= fac[A.size() - 1 - i]; a.erase(ans[i]); } return ans; }

Compilation message (stderr)

bartender.cpp: In function 'std::vector<int> BlendWines(int, std::vector<int>)':
bartender.cpp:13:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i <= R.size(); ++i) a.insert(i);
                  ~~^~~~~~~~~~~
bartender.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < R.size(); ++i) fac[i] = i * fac[i - 1];
                  ~~^~~~~~~~~~
bartender.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < R.size(); ++i) {
                  ~~^~~~~~~~~~
bartender.cpp:20:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < R.size(); ++i) {
                  ~~^~~~~~~~~~

taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i <= A.size(); ++i) a.insert(i);
                  ~~^~~~~~~~~~~
taster.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < A.size(); ++i) fac[i] = i * fac[i - 1];
                  ~~^~~~~~~~~~
taster.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < A.size(); ++i) {
                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...