Submission #150746

# Submission time Handle Problem Language Result Execution time Memory
150746 2019-09-01T08:53:14 Z Dopatii(#3751, bogdan10bos, Gioto, Bodo171) Wine Tasting (FXCUP4_wine) C++17
4 / 100
11 ms 1068 KB
#include "bartender.h"
#include <bits/stdc++.h>
using namespace std;

int f[35], used[35], pos[35];
std::vector<int> BlendWines(int K, std::vector<int> R){
	int N = R.size();
    if(K >= N) return R;
	vector <int> v(N);

	for(int i = 0; i < N ; ++i) pos[R[i]] = i;

	int NR = K / 2 + K % 2, ram = N;
	for(int val = N; val >= 1 && NR >= 1 ; --val){
        if(used[val]) continue ;
        --NR;
        int i = val;

        while(i >= 1){
            --ram;
            used[i] = 1;
            v[pos[i]] = K;
            if(pos[i] < pos[i - 1]) break ;
            --i;
        }

        --K;
	}


	int sz = ram / K, rest = ram % K;

    for(int i = ram; i >= 1 && K >= 1 ; --i, --K){
        int j = i - sz + 1;
        if(rest > 0) --j, --rest;

        for(int t = j; t <= i ; ++t) v[pos[t]] = K;

        i = j;
    }

    for(auto it : v) printf("%d ", it);

	return v;
}










#include "taster.h"
#include <bits/stdc++.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];
}

std::vector<int> SortWines(int K, std::vector<int> A) {
	int N = A.size();
	if(N <= K) return A;
	vector <int> v(N);

	int cnt = K / 2 + K % 2, NR = N;

    while(cnt--){
        for(int i = A.size() - 1; i >= 0 ; --i) if(A[i] == K) v[i] = NR--;
        --K;
    }

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

	mt19937 g(chrono::high_resolution_clock::now().time_since_epoch().count());
	for(int i = 1; i <= K; i++)
		shuffle(pos[i].begin(), pos[i].end(), g);

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

    int no = 0;
    for(int i = 1; i <= K ; ++i){
        for(auto it : pos[i])
            v[it] = ++no;

    }

    return v;
}

/**
    sort(pos[i].begin(), pos[i].end(),
    [&](int a, int b) { return myCompare(a, b); } );
**/
# Verdict Execution time Memory Grader output
1 Correct 11 ms 880 KB Correct
2 Correct 8 ms 772 KB Correct
3 Correct 10 ms 908 KB Correct
4 Correct 10 ms 780 KB Correct
5 Correct 10 ms 772 KB Correct
6 Correct 9 ms 880 KB Correct
7 Correct 9 ms 860 KB Correct
8 Correct 9 ms 772 KB Correct
9 Correct 10 ms 908 KB Correct
10 Correct 9 ms 780 KB Correct
11 Correct 10 ms 664 KB Correct
12 Correct 9 ms 1024 KB Correct
13 Correct 9 ms 780 KB Correct
14 Correct 10 ms 780 KB Correct
15 Correct 10 ms 732 KB Correct
16 Partially correct 9 ms 908 KB Wrong
17 Partially correct 10 ms 908 KB Wrong
18 Partially correct 9 ms 772 KB Wrong
19 Partially correct 9 ms 1068 KB Wrong
20 Partially correct 10 ms 908 KB Wrong
21 Partially correct 9 ms 908 KB Wrong
22 Partially correct 9 ms 1020 KB Wrong
23 Partially correct 10 ms 772 KB Wrong
24 Partially correct 10 ms 864 KB Wrong
25 Partially correct 9 ms 772 KB Wrong
26 Partially correct 10 ms 772 KB Wrong
27 Partially correct 8 ms 644 KB Wrong
28 Partially correct 9 ms 860 KB Wrong
29 Partially correct 9 ms 772 KB Wrong
30 Partially correct 9 ms 772 KB Wrong
31 Partially correct 10 ms 908 KB Wrong
32 Partially correct 10 ms 656 KB Wrong
33 Partially correct 10 ms 908 KB Wrong
34 Partially correct 9 ms 908 KB Wrong
35 Partially correct 9 ms 644 KB Wrong
36 Partially correct 8 ms 792 KB Wrong
37 Partially correct 9 ms 772 KB Wrong
38 Partially correct 9 ms 772 KB Wrong
39 Partially correct 8 ms 772 KB Wrong
40 Partially correct 9 ms 772 KB Wrong
41 Partially correct 10 ms 884 KB Wrong
42 Partially correct 9 ms 772 KB Wrong
43 Partially correct 9 ms 772 KB Wrong
44 Partially correct 9 ms 772 KB Wrong
45 Partially correct 10 ms 772 KB Wrong
46 Partially correct 10 ms 772 KB Wrong
47 Partially correct 10 ms 908 KB Wrong
48 Partially correct 9 ms 780 KB Wrong
49 Partially correct 9 ms 644 KB Wrong
50 Partially correct 10 ms 772 KB Wrong
51 Partially correct 9 ms 772 KB Wrong
52 Partially correct 9 ms 772 KB Wrong
53 Partially correct 9 ms 780 KB Wrong
54 Partially correct 9 ms 644 KB Wrong
55 Partially correct 9 ms 772 KB Wrong
56 Partially correct 9 ms 772 KB Wrong
57 Partially correct 10 ms 908 KB Wrong
58 Partially correct 10 ms 772 KB Wrong
59 Partially correct 9 ms 644 KB Wrong
60 Partially correct 8 ms 712 KB Wrong
61 Partially correct 8 ms 772 KB Wrong
62 Partially correct 9 ms 644 KB Wrong
63 Partially correct 9 ms 784 KB Wrong
64 Partially correct 9 ms 884 KB Wrong
65 Partially correct 8 ms 644 KB Wrong
66 Partially correct 8 ms 644 KB Wrong
67 Partially correct 9 ms 908 KB Wrong
68 Partially correct 9 ms 884 KB Wrong
69 Partially correct 9 ms 644 KB Wrong
70 Partially correct 10 ms 780 KB Wrong
71 Partially correct 9 ms 644 KB Wrong
72 Partially correct 9 ms 772 KB Wrong
73 Partially correct 8 ms 908 KB Wrong
74 Partially correct 8 ms 772 KB Wrong
75 Partially correct 10 ms 644 KB Wrong
76 Correct 8 ms 772 KB Correct
77 Correct 10 ms 908 KB Correct
78 Correct 9 ms 644 KB Correct
79 Partially correct 8 ms 644 KB Wrong
80 Partially correct 9 ms 780 KB Wrong
81 Partially correct 10 ms 908 KB Wrong
82 Partially correct 9 ms 772 KB Wrong
83 Partially correct 9 ms 908 KB Wrong
84 Partially correct 9 ms 772 KB Wrong
85 Partially correct 9 ms 796 KB Wrong
86 Partially correct 10 ms 772 KB Wrong
87 Partially correct 8 ms 780 KB Wrong
88 Correct 10 ms 772 KB Correct
89 Correct 9 ms 780 KB Correct
90 Correct 9 ms 956 KB Correct
91 Partially correct 9 ms 644 KB Wrong
92 Partially correct 10 ms 908 KB Wrong
93 Partially correct 9 ms 924 KB Wrong
94 Partially correct 9 ms 644 KB Wrong
95 Partially correct 9 ms 908 KB Wrong
96 Partially correct 10 ms 772 KB Wrong
97 Partially correct 8 ms 772 KB Wrong
98 Partially correct 8 ms 772 KB Wrong
99 Partially correct 9 ms 940 KB Wrong
100 Partially correct 8 ms 644 KB Wrong
101 Partially correct 9 ms 772 KB Wrong
102 Partially correct 9 ms 908 KB Wrong
103 Correct 9 ms 772 KB Correct
104 Correct 9 ms 772 KB Correct
105 Correct 9 ms 780 KB Correct
106 Partially correct 9 ms 908 KB Wrong
107 Partially correct 9 ms 644 KB Wrong
108 Partially correct 10 ms 908 KB Wrong
109 Partially correct 9 ms 780 KB Wrong
110 Partially correct 10 ms 788 KB Wrong
111 Partially correct 9 ms 824 KB Wrong
112 Partially correct 9 ms 908 KB Wrong
113 Partially correct 9 ms 908 KB Wrong
114 Partially correct 9 ms 644 KB Wrong
115 Partially correct 9 ms 716 KB Wrong
116 Partially correct 8 ms 772 KB Wrong
117 Partially correct 9 ms 772 KB Wrong
118 Partially correct 9 ms 1012 KB Wrong
119 Partially correct 9 ms 908 KB Wrong
120 Partially correct 9 ms 980 KB Wrong