Submission #247374

# Submission time Handle Problem Language Result Execution time Memory
247374 2020-07-11T09:08:23 Z shenxy Wine Tasting (FXCUP4_wine) C++17
87 / 100
11 ms 1052 KB
#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), f12, rem;
	__int128_t x = 0, fac[R.size()];
	for (int i = 0; i < R.size(); ++i) {
		if (R[i] <= 11) f12.push_back(i);
		else rem.push_back(i);
	}
	os a;
	for (int i = 12; 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 < rem.size(); ++i) {
		x = x + a.order_of_key(R[rem[i]]) * fac[rem.size() - i - 1];
		a.erase(R[rem[i]]);
	}
	for (int i = 0; i < f12.size(); ++i) {
		ans[f12[i]] = x % 3 + 1;
		x /= 3;
	}
	for (int i = 0; i < rem.size(); ++i) {
		ans[rem[i]] = x % 5 + 4;
		x /= 5;
	}
	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> merge_sort(vector<int> inp) {
	if (inp.size() == 1) return inp;
	vector<int> l, r, ans;
	for (int i = 0; i < inp.size() / 2; ++i) l.push_back(inp[i]);
	for (int i = inp.size() / 2; i < inp.size(); ++i) r.push_back(inp[i]);
	l = merge_sort(l), r = merge_sort(r);
	int lptr = 0, rptr = 0;
	while (lptr != l.size() || rptr != r.size()) {
		if (lptr == l.size()) ans.push_back(r[rptr++]);
		else if (rptr == r.size()) ans.push_back(l[lptr++]);
		else if (Compare(l[lptr], r[rptr]) == 1) ans.push_back(r[rptr++]);
		else ans.push_back(l[lptr++]);
	}
	return ans;
}
vector<int> SortWines(int K, vector<int> A) {
	vector<int> ans(A.size(), 0), f12, rem;
	__int128_t x = 0, fac[A.size()];
	for (int i = 0; i < A.size(); ++i) {
		if (A[i] < 4) f12.push_back(i);
		else rem.push_back(i);
	}
	for (int i = rem.size() - 1; i >= 0; --i) x = x * 5 + A[rem[i]] - 4;
	for (int i = f12.size() - 1; i >= 0; --i) x = x * 3 + A[f12[i]] - 1;
	os a;
	for (int i = 12; 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 < rem.size(); ++i) {
		ans[rem[i]] = *a.find_by_order(x / fac[rem.size() - 1 - i]);
		x %= fac[rem.size() - 1 - i];
		a.erase(ans[rem[i]]);
	}
	vector<int> ord = merge_sort(f12);
	for (int i = 0; i < ord.size(); ++i) ans[ord[i]] = i + 1;
	return ans;
}

Compilation message

bartender.cpp: In function 'std::vector<int> BlendWines(int, std::vector<int>)':
bartender.cpp:12:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < R.size(); ++i) {
                  ~~^~~~~~~~~~
bartender.cpp:17:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 12; i <= R.size(); ++i) a.insert(i);
                   ~~^~~~~~~~~~~
bartender.cpp:19: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:20:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < rem.size(); ++i) {
                  ~~^~~~~~~~~~~~
bartender.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < f12.size(); ++i) {
                  ~~^~~~~~~~~~~~
bartender.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < rem.size(); ++i) {
                  ~~^~~~~~~~~~~~

taster.cpp: In function 'std::vector<int> merge_sort(std::vector<int>)':
taster.cpp:12:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < inp.size() / 2; ++i) l.push_back(inp[i]);
                  ~~^~~~~~~~~~~~~~~~
taster.cpp:13:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = inp.size() / 2; i < inp.size(); ++i) r.push_back(inp[i]);
                               ~~^~~~~~~~~~~~
taster.cpp:16:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (lptr != l.size() || rptr != r.size()) {
         ~~~~~^~~~~~~~~~~
taster.cpp:16:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (lptr != l.size() || rptr != r.size()) {
                             ~~~~~^~~~~~~~~~~
taster.cpp:17:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (lptr == l.size()) ans.push_back(r[rptr++]);
       ~~~~~^~~~~~~~~~~
taster.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   else if (rptr == r.size()) ans.push_back(l[lptr++]);
            ~~~~~^~~~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:27:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < A.size(); ++i) {
                  ~~^~~~~~~~~~
taster.cpp:34:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 12; i <= A.size(); ++i) a.insert(i);
                   ~~^~~~~~~~~~~
taster.cpp:36: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:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < rem.size(); ++i) {
                  ~~^~~~~~~~~~~~
taster.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < ord.size(); ++i) ans[ord[i]] = i + 1;
                  ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1032 KB Correct
2 Correct 8 ms 672 KB Correct
3 Correct 8 ms 792 KB Correct
4 Correct 8 ms 668 KB Correct
5 Correct 8 ms 672 KB Correct
6 Correct 8 ms 648 KB Correct
7 Correct 9 ms 648 KB Correct
8 Correct 10 ms 672 KB Correct
9 Correct 8 ms 792 KB Correct
10 Correct 9 ms 660 KB Correct
11 Correct 9 ms 676 KB Correct
12 Correct 9 ms 672 KB Correct
13 Correct 9 ms 668 KB Correct
14 Correct 9 ms 672 KB Correct
15 Correct 8 ms 792 KB Correct
16 Correct 8 ms 676 KB Correct
17 Correct 8 ms 672 KB Correct
18 Correct 9 ms 668 KB Correct
19 Correct 8 ms 648 KB Correct
20 Correct 9 ms 796 KB Correct
21 Correct 9 ms 804 KB Correct
22 Correct 8 ms 800 KB Correct
23 Correct 8 ms 668 KB Correct
24 Correct 10 ms 676 KB Correct
25 Correct 9 ms 648 KB Correct
26 Correct 8 ms 800 KB Correct
27 Correct 9 ms 672 KB Correct
28 Correct 9 ms 668 KB Correct
29 Correct 9 ms 776 KB Correct
30 Correct 9 ms 1024 KB Correct
31 Correct 10 ms 668 KB Correct
32 Correct 8 ms 648 KB Correct
33 Correct 9 ms 788 KB Correct
34 Correct 8 ms 668 KB Correct
35 Correct 9 ms 904 KB Correct
36 Correct 9 ms 896 KB Correct
37 Correct 9 ms 672 KB Correct
38 Correct 9 ms 676 KB Correct
39 Correct 8 ms 676 KB Correct
40 Correct 9 ms 668 KB Correct
41 Correct 9 ms 796 KB Correct
42 Correct 9 ms 804 KB Correct
43 Correct 8 ms 804 KB Correct
44 Correct 9 ms 664 KB Correct
45 Correct 8 ms 792 KB Correct
46 Correct 8 ms 800 KB Correct
47 Correct 8 ms 668 KB Correct
48 Correct 8 ms 672 KB Correct
49 Correct 8 ms 832 KB Correct
50 Correct 9 ms 676 KB Correct
51 Correct 8 ms 672 KB Correct
52 Correct 8 ms 664 KB Correct
53 Correct 8 ms 676 KB Correct
54 Correct 9 ms 796 KB Correct
55 Correct 9 ms 928 KB Correct
56 Correct 8 ms 668 KB Correct
57 Correct 10 ms 1028 KB Correct
58 Correct 8 ms 648 KB Correct
59 Correct 8 ms 668 KB Correct
60 Correct 8 ms 676 KB Correct
61 Correct 9 ms 648 KB Correct
62 Correct 8 ms 776 KB Correct
63 Correct 8 ms 668 KB Correct
64 Correct 8 ms 792 KB Correct
65 Correct 10 ms 796 KB Correct
66 Correct 9 ms 656 KB Correct
67 Correct 8 ms 792 KB Correct
68 Correct 9 ms 1052 KB Correct
69 Correct 9 ms 648 KB Correct
70 Correct 8 ms 672 KB Correct
71 Correct 10 ms 788 KB Correct
72 Correct 9 ms 800 KB Correct
73 Correct 8 ms 796 KB Correct
74 Correct 8 ms 804 KB Correct
75 Correct 10 ms 668 KB Correct
76 Correct 10 ms 648 KB Correct
77 Correct 9 ms 800 KB Correct
78 Correct 9 ms 896 KB Correct
79 Correct 9 ms 648 KB Correct
80 Correct 8 ms 900 KB Correct
81 Correct 8 ms 812 KB Correct
82 Correct 9 ms 904 KB Correct
83 Correct 9 ms 896 KB Correct
84 Correct 9 ms 664 KB Correct
85 Correct 8 ms 648 KB Correct
86 Correct 8 ms 672 KB Correct
87 Correct 9 ms 892 KB Correct
88 Correct 11 ms 668 KB Correct
89 Correct 9 ms 664 KB Correct
90 Correct 9 ms 1024 KB Correct
91 Correct 8 ms 900 KB Correct
92 Correct 8 ms 908 KB Correct
93 Correct 9 ms 792 KB Correct
94 Correct 10 ms 920 KB Correct
95 Correct 9 ms 1028 KB Correct
96 Correct 8 ms 896 KB Correct
97 Correct 8 ms 668 KB Correct
98 Correct 9 ms 664 KB Correct
99 Correct 9 ms 1020 KB Correct
100 Correct 8 ms 672 KB Correct
101 Correct 9 ms 676 KB Correct
102 Correct 10 ms 664 KB Correct
103 Correct 8 ms 672 KB Correct
104 Correct 8 ms 676 KB Correct
105 Correct 9 ms 900 KB Correct
106 Correct 8 ms 776 KB Correct
107 Correct 9 ms 784 KB Correct
108 Partially correct 8 ms 656 KB Wrong
109 Partially correct 8 ms 904 KB Wrong
110 Partially correct 9 ms 660 KB Wrong
111 Partially correct 8 ms 672 KB Wrong
112 Partially correct 9 ms 900 KB Wrong
113 Partially correct 8 ms 800 KB Wrong
114 Partially correct 9 ms 784 KB Wrong
115 Partially correct 8 ms 676 KB Wrong
116 Partially correct 9 ms 796 KB Wrong
117 Correct 9 ms 896 KB Correct
118 Partially correct 9 ms 648 KB Wrong
119 Partially correct 8 ms 804 KB Wrong
120 Partially correct 9 ms 792 KB Wrong