Submission #148532

# Submission time Handle Problem Language Result Execution time Memory
148532 2019-09-01T04:37:08 Z Dopatii(#3751, bogdan10bos, Gioto, Bodo171) Wine Tasting (FXCUP4_wine) C++17
43 / 100
11 ms 1052 KB
#include <bits/stdc++.h>
#include "bartender.h"

using namespace std;

vector<int> BlendWines(int K, vector<int> R)
{
	int N = R.size();
	vector<int> pos;
	pos.resize(R.size());
	for(int i = 0; i < R.size(); i++)	R[i]--;
	for(int i = 0; i < R.size(); i++) pos[ R[i] ] = i;

	vector<int> ret;
	ret.resize(R.size());

	int cnt = (K + 1) / 2;
	for(int i = 0; i < cnt && i < N; i++)
		ret[ pos[i] ] = K - i;

	vector<int> order;
	for(int i = 0; i < N; i++)
		if(ret[i] == 0)	order.push_back(i);

	sort(order.begin(), order.end(),
			[&](int a, int b) { return R[a] < R[b]; });

	int myk = K / 2;
	for(int i = 0; i < order.size(); i++)
		ret[ order[i] ] = (myk - (i % myk));
	return ret;
}
#include <bits/stdc++.h>
#include "taster.h"

using namespace std;

map<int, int> mp[35];

int myCompare(int x, int y)
{
	if(mp[x].count(y))	return mp[x][y];
	int ans = Compare(x, y);
	mp[x][y] = (ans == -1 ? 1 : 0);
	mp[y][x] = (ans == 1 ? 1 : 0);
	return mp[x][y];
}

vector<int> SortWines(int K, vector<int> A)
{
	int N = A.size();
	vector<int> ret;
	ret.resize(N);

	vector<int> pos[35];
	for(int i = 0; i < N; i++)
		pos[ A[i] ].push_back(i);

	for(int i = 1; i <= K; i++)
		sort(pos[i].begin(), pos[i].end(),
			[&](int a, int b) { return myCompare(a, b); } );

	int val = 1;
	for(int i = 0; i < 30; i++)
	{
		for(int j = K; j >= 1; j--)
			if(!pos[j].empty())
			{
				ret[ pos[j][0] ] = val;
				val++;
				pos[j].erase(pos[j].begin());
			}
	}

	return ret;
}

Compilation message

bartender.cpp: In function 'std::vector<int> BlendWines(int, std::vector<int>)':
bartender.cpp:11:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < R.size(); i++) R[i]--;
                 ~~^~~~~~~~~~
bartender.cpp:12:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < R.size(); i++) pos[ R[i] ] = i;
                 ~~^~~~~~~~~~
bartender.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < order.size(); i++)
                 ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 908 KB Correct
2 Correct 9 ms 1016 KB Correct
3 Correct 10 ms 924 KB Correct
4 Correct 8 ms 772 KB Correct
5 Correct 8 ms 780 KB Correct
6 Correct 9 ms 644 KB Correct
7 Correct 9 ms 772 KB Correct
8 Correct 9 ms 776 KB Correct
9 Correct 9 ms 696 KB Correct
10 Correct 8 ms 772 KB Correct
11 Correct 9 ms 908 KB Correct
12 Correct 9 ms 988 KB Correct
13 Correct 10 ms 772 KB Correct
14 Correct 9 ms 644 KB Correct
15 Correct 10 ms 772 KB Correct
16 Correct 10 ms 644 KB Correct
17 Correct 9 ms 772 KB Correct
18 Correct 9 ms 804 KB Correct
19 Correct 9 ms 772 KB Correct
20 Correct 8 ms 884 KB Correct
21 Correct 10 ms 884 KB Correct
22 Correct 9 ms 784 KB Correct
23 Correct 9 ms 700 KB Correct
24 Correct 10 ms 644 KB Correct
25 Correct 10 ms 1052 KB Correct
26 Correct 10 ms 868 KB Correct
27 Correct 10 ms 908 KB Correct
28 Correct 9 ms 772 KB Correct
29 Correct 9 ms 908 KB Correct
30 Correct 10 ms 780 KB Correct
31 Correct 10 ms 780 KB Correct
32 Correct 9 ms 644 KB Correct
33 Correct 9 ms 792 KB Correct
34 Correct 10 ms 956 KB Correct
35 Correct 10 ms 908 KB Correct
36 Correct 10 ms 908 KB Correct
37 Correct 10 ms 772 KB Correct
38 Correct 10 ms 772 KB Correct
39 Correct 10 ms 908 KB Correct
40 Correct 10 ms 908 KB Correct
41 Correct 10 ms 788 KB Correct
42 Correct 10 ms 868 KB Correct
43 Correct 9 ms 908 KB Correct
44 Correct 10 ms 644 KB Correct
45 Correct 10 ms 644 KB Correct
46 Correct 9 ms 772 KB Correct
47 Correct 9 ms 772 KB Correct
48 Correct 10 ms 772 KB Correct
49 Correct 9 ms 772 KB Correct
50 Correct 9 ms 772 KB Correct
51 Correct 8 ms 644 KB Correct
52 Correct 9 ms 772 KB Correct
53 Correct 10 ms 644 KB Correct
54 Correct 10 ms 908 KB Correct
55 Correct 9 ms 780 KB Correct
56 Correct 10 ms 880 KB Correct
57 Correct 8 ms 780 KB Correct
58 Correct 8 ms 772 KB Correct
59 Correct 9 ms 780 KB Correct
60 Correct 9 ms 924 KB Correct
61 Correct 10 ms 780 KB Correct
62 Correct 9 ms 908 KB Correct
63 Correct 10 ms 772 KB Correct
64 Correct 8 ms 780 KB Correct
65 Correct 8 ms 920 KB Correct
66 Correct 8 ms 780 KB Correct
67 Partially correct 9 ms 908 KB Wrong
68 Correct 10 ms 772 KB Correct
69 Partially correct 9 ms 772 KB Wrong
70 Partially correct 10 ms 644 KB Wrong
71 Partially correct 9 ms 896 KB Wrong
72 Partially correct 9 ms 792 KB Wrong
73 Partially correct 9 ms 780 KB Wrong
74 Partially correct 10 ms 772 KB Wrong
75 Partially correct 11 ms 988 KB Wrong
76 Correct 8 ms 1016 KB Correct
77 Correct 11 ms 908 KB Correct
78 Correct 8 ms 772 KB Correct
79 Correct 9 ms 784 KB Correct
80 Correct 10 ms 732 KB Correct
81 Correct 8 ms 664 KB Correct
82 Partially correct 10 ms 780 KB Wrong
83 Partially correct 8 ms 772 KB Wrong
84 Partially correct 10 ms 888 KB Wrong
85 Correct 11 ms 644 KB Correct
86 Partially correct 9 ms 888 KB Wrong
87 Partially correct 10 ms 784 KB Wrong
88 Correct 8 ms 1040 KB Correct
89 Correct 9 ms 772 KB Correct
90 Correct 10 ms 884 KB Correct
91 Correct 9 ms 772 KB Correct
92 Correct 9 ms 884 KB Correct
93 Correct 10 ms 900 KB Correct
94 Partially correct 9 ms 1012 KB Wrong
95 Partially correct 8 ms 772 KB Wrong
96 Partially correct 9 ms 780 KB Wrong
97 Partially correct 9 ms 772 KB Wrong
98 Partially correct 8 ms 772 KB Wrong
99 Partially correct 9 ms 788 KB Wrong
100 Correct 9 ms 772 KB Correct
101 Partially correct 9 ms 884 KB Wrong
102 Partially correct 10 ms 884 KB Wrong
103 Correct 9 ms 772 KB Correct
104 Correct 8 ms 772 KB Correct
105 Correct 10 ms 772 KB Correct
106 Correct 9 ms 900 KB Correct
107 Correct 10 ms 908 KB Correct
108 Partially correct 9 ms 772 KB Wrong
109 Partially correct 9 ms 772 KB Wrong
110 Partially correct 8 ms 772 KB Wrong
111 Partially correct 9 ms 772 KB Wrong
112 Partially correct 9 ms 776 KB Wrong
113 Partially correct 8 ms 780 KB Wrong
114 Partially correct 9 ms 952 KB Wrong
115 Correct 8 ms 776 KB Correct
116 Partially correct 9 ms 772 KB Wrong
117 Partially correct 9 ms 792 KB Wrong
118 Partially correct 8 ms 908 KB Wrong
119 Partially correct 10 ms 772 KB Wrong
120 Partially correct 10 ms 908 KB Wrong