# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247273 | jamielim | Wine Tasting (FXCUP4_wine) | C++17 | 10 ms | 1008 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=1000000007; //998244353; //
const ld PI=3.1415926535898;
const ld EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}
#include "bartender.h"
std::vector<int> BlendWines(int K, std::vector<int> R){
int N = R.size();
vector<int> a(N);
for(int i=0;i<N;i++){
if(R[i]==N)a[i]=K;
else if(R[i]==(N-1)/2&&N%2==0){
a[i]=1;
}else{
a[i]=min(R[i],N-R[i]);
}
}
return a;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=1000000007; //998244353; //
const ld PI=3.1415926535898;
const ld EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}
#include "taster.h"
//int Compare(int P,int Q);
std::vector<int> SortWines(int K, std::vector<int> A) {
int N = A.size();
vector<int> ans(N);
vector<int> c[K+1];
for(int i=0;i<N;i++){c[A[i]].pb(i);}
//for(int i=1;i<=K;i++){for(int j:c[i])printf("%d ",j);printf("\n");}
ans[c[K][0]]=N;
if(N%2==0){
int x=Compare(c[1][0],c[1][1]),y=Compare(c[1][0],c[1][2]),z=Compare(c[1][1],c[1][2]);
if(x<0&&y<0){
ans[c[1][0]]=1;
if(z<0)ans[c[1][1]]=(N-1)/2,ans[c[1][2]]=N-1;
else ans[c[1][1]]=N-1,ans[c[1][2]]=(N-1)/2;
}else if(x<0||y<0){
ans[c[1][0]]=(N-1)/2;
if(z<0)ans[c[1][1]]=1,ans[c[1][2]]=N-1;
else ans[c[1][1]]=N-1,ans[c[1][2]]=1;
}else{
ans[c[1][0]]=N-1;
if(z<0)ans[c[1][1]]=1,ans[c[1][2]]=(N-1)/2;
else ans[c[1][1]]=(N-1)/2,ans[c[1][2]]=1;
}
for(int i=2;i<K;i++){
int x=Compare(c[i][0],c[i][1]);
if(x<0){
ans[c[i][0]]=i;
ans[c[i][1]]=N-i;
}else{
ans[c[i][0]]=N-i;
ans[c[i][1]]=i;
}
}
}else{
for(int i=1;i<K;i++){
if(c[i].empty())continue;
int x=Compare(c[i][0],c[i][1]);
if(x<0){
ans[c[i][0]]=i;
ans[c[i][1]]=N-i;
}else{
ans[c[i][0]]=N-i;
ans[c[i][1]]=i;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |