Submission #247222

#TimeUsernameProblemLanguageResultExecution timeMemory
247222errorgornWine Tasting (FXCUP4_wine)C++17
0 / 100
9 ms1020 KiB
#include <bits/stdc++.h> #include "bartender.h" using namespace std; #define ll long long #define fi first #define se second #define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--)) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() const int val[]={1,10,1,10,1,10,2,9,2,9,2,9,3,8,3,8,3,8,4,7,4,7,4,7,5,6,5,6,5,6}; std::vector<int> BlendWines(int k, std::vector<int> r){ int n=sz(r); vector<int> v; rep(x,0,n){ v.push_back(x); } sort(all(v),[r](int i,int j){ return r[i]<r[j]; }); vector<int> ans(n); rep(x,0,n){ ans[x]=val[r[x]-1]; } //rep(x,0,n) cout<<ans[x]<<" ";cout<<endl; return ans; }
#include <bits/stdc++.h> #include "taster.h" using namespace std; #define ll long long #define fi first #define se second #define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--)) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() const int val[]={1,10,2,9,3,8,4,7,5,6}; int temp[6]; std::vector<int> SortWines(int k, std::vector<int> a) { int n=sz(a); vector<int> ans; rep(pos,0,5){ vector<int> small; vector<int> big; rep(x,0,n){ if (a[x]==val[pos*2]) small.push_back(x); if (a[x]==val[pos*2+1]) big.push_back(x); } memset(temp,-1,sizeof(temp)); for (auto &it:small){ if (temp[0]==-1){ temp[0]=it; } else if (temp[2]==-1){ temp[2]=it; if (Compare(temp[0],temp[2])==1) swap(temp[0],temp[2]); } else{ temp[4]=it; if (Compare(temp[2],temp[4])==1) swap(temp[2],temp[4]); if (Compare(temp[0],temp[2])==1) swap(temp[2],temp[4]); } } if (sz(big)==1) temp[3]=temp[5]=-2; if (sz(big)==2) temp[5]=-2; for (auto &it:big){ //if else spam is my passion if (temp[1]==-1 && temp[3]==-1 && temp[5]==-1){ if (Compare(it,temp[2])==-1) temp[1]=it; else if (Compare(it,temp[4])==-1) temp[3]=it; else temp[5]=it; } else if (temp[1]==-1 && temp[3]==-1){ if (Compare(it,temp[2])==-1) temp[1]=it; else temp[3]=it; } else if (temp[1]==-1 && temp[5]==-1){ if (Compare(it,temp[2])==-1) temp[1]=it; else temp[5]=it; } else if (temp[3]==-1 && temp[5]==-1){ if (Compare(it,temp[4])==-1) temp[3]=it; else temp[5]=it; } else if (temp[1]==-1){ temp[1]=it; } else if (temp[3]==-1){ temp[3]=it; } else{ temp[5]=it; } } rep(x,0,6) if (temp[x]!=-1) ans.push_back(temp[x]); } //rep(x,0,n) cout<<ans[x]<<" ";cout<<endl; vector<int> perm(n); rep(x,0,n) perm[ans[x]]=x+1; return perm; }
#Verdict Execution timeMemoryGrader output
Fetching results...