# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
760180 | denniskim | Wine Tasting (FXCUP4_wine) | C++17 | 2 ms | 604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bartender.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())
vector<ll> BlendWines(ll K, vector<ll> R)
{
ll n = (ll)R.size();
vector<ll> ret;
for(ll i = 0 ; i < n ; i++)
ret.push_back(0);
for(ll i = 0 ; i < n ; i++)
ret[i] = (R[i] - 1) % 10 + 1;
return ret;
}
#include "taster.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())
vector<int> SortWines(int K, vector<int> A)
{
ll maxx = 0;
ll n = (ll)A.size();
vector<ll> ans;
for(ll i = 0 ; i < n ; i++)
{
ans.push_back(0);
maxx = max(maxx, A[i]);
}
vector<ll> on, son;
for(ll i = 0 ; i < n ; i++)
{
if(A[i] == 1)
on.push_back(i);
}
if((ll)on.size() == 1)
son = on;
else if((ll)on.size() == 2)
{
ll qry = Compare(on[0], on[1]);
if(qry == -1)
{
son.push_back(on[0]);
son.push_back(on[1]);
}
else
{
son.push_back(on[1]);
son.push_back(on[0]);
}
}
else
{
ll qry1 = Compare(on[0], on[1]);
ll qry2 = Compare(on[0], on[2]);
ll qry3 = Compare(on[1], on[2]);
ll sum = on[0] + on[1] + on[2];
ll w1 = 0, w3 = 0;
if(qry1 == 1 && qry2 == 1)
w3 = on[0], sum -= on[0];
else if(qry1 == -1 && qry3 == 1)
w3 = on[1], sum -= on[1];
else if(qry2 == -1 && qry3 == -1)
w3 = on[2], sum -= on[2];
if(qry1 == -1 && qry2 == -1)
w1 = on[0], sum -= on[0];
else if(qry1 == 1 && qry3 == -1)
w1 = on[1], sum -= on[1];
else if(qry2 == 1 && qry3 == 1)
w1 = on[2], sum -= on[2];
son.push_back(w1);
son.push_back(sum);
son.push_back(w3);
}
for(ll i = 0 ; i < (ll)son.size() ; i++)
ans[son[i]] = i * 10 + 1;
for(ll i = 2 ; i <= maxx ; i++)
{
vector<ll> w;
for(ll j = 0 ; j < n ; j++)
{
if(A[j] == i)
w.push_back(j);
}
if((ll)w.size() == 1)
{
ans[w[0]] = i;
continue;
}
if(son.size() == 2)
{
ll qry1 = Compare(son[1], w[0]);
if(qry1 == -1)
{
ans[w[0]] = 10 + i;
if((ll)w.size() >= 2)
ans[w[1]] = i;
}
else
{
ans[w[0]] = i;
if((ll)w.size() >= 2)
ans[w[1]] = 10 + i;
}
}
else
{
vector<ll> tmp = son;
vector<ll> help;
help.push_back(0);
help.push_back(10);
help.push_back(20);
for(ll j = 0 ; j < (ll)w.size() ; j++)
{
if((ll)tmp.size() == 3)
{
ll qry = Compare(tmp[1], w[j]);
if(qry == 1)
{
ans[w[j]] = i + help[0];
tmp[0] = tmp[1];
tmp[1] = tmp[2];
tmp.pop_back();
help[0] = help[1];
help[1] = help[2];
help.pop_back();
continue;
}
qry = Compare(tmp[2], w[j]);
if(qry == -1)
{
ans[w[j]] = i + help[2];
tmp.pop_back();
help.pop_back();
}
else
{
ans[w[j]] = i + help[1];
tmp[1] = tmp[2];
tmp.pop_back();
help[1] = help[2];
help.pop_back();
}
}
else if((ll)tmp.size() == 2)
{
ll qry = Compare(tmp[1], w[j]);
if(qry == 1)
{
ans[w[j]] = i + help[0];
tmp[0] = tmp[1];
tmp.pop_back();
help[0] = help[1];
help.pop_back();
}
else
{
ans[w[j]] = i + help[1];
tmp.pop_back();
help.pop_back();
}
}
else
ans[w[j]] = i + help[0];
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |