Submission #150884

#TimeUsernameProblemLanguageResultExecution timeMemory
150884khsoo01Wine Tasting (FXCUP4_wine)C++17
65 / 100
11 ms1032 KiB
#include "bartender.h" using namespace std; vector<int> BlendWines(int K, vector<int> R) { int N = R.size(), L = max(0, N - 27); for(int i=0;i<N;i++) R[i]--; vector<int> V; vector<int> X; for(int i=0;i<N;i++) { V.push_back(0); if(R[i] >= 27) { X.push_back(R[i] - 26); V[i] = 10; } } for(int i=L+1;i<=9;i++) { X.push_back(i); } for(int i=0;i<N;i++) { if(V[i] == 10) continue; V[i] = X[R[i] % 9]; } return V; }
#include "taster.h" #include<cstdio> using namespace std; vector<int> val[15], tens; void sortA (vector<int> &V) { for(int i=0;i<V.size();i++) { for(int j=i-1;j>=0;j--) { if(Compare(V[j], V[j+1]) == 1) swap(V[j], V[j+1]); else break; } } } void sortB (vector<int> &V, vector<int> &T) { vector<int> R; for(int i=0;i<V.size();i++) R.push_back(-1); for(int i=0;i<V.size();i++) { int lst = 0; for(int j=V.size();j--;) { if(R[j] == -1) { lst = j; break; } } for(int j=0;j<V.size();j++) { if(j == lst || (R[j] == -1 && Compare(T[j+1], V[i]) == 1)) { R[j] = V[i]; break; } } } swap(R, V); } vector<int> SortWines(int K, vector<int> A) { int N = A.size(), L = 0; vector<int> R; for(int i=0;i<N;i++) { R.push_back(0); if(A[i] == 10) { tens.push_back(i); L++; } else { val[A[i]].push_back(i); } } vector<int> hds; for(int i=1;i<=L;i++) { sortA(val[i]); hds.push_back(val[i][0]); } sortA(hds); for(int i=0;i<hds.size();i++) { int T = A[hds[i]]; R[tens[i]] = 26 + T; for(int j=0;j<val[T].size();j++) { R[val[T][j]] = j * 9 + i; } } for(int i=L+1;i<=9;i++) { if(i == 1) sortA(val[i]); else sortB(val[i], val[1]); for(int j=0;j<val[i].size();j++) { R[val[i][j]] = j * 9 + i - 1; } } for(int i=0;i<N;i++) R[i]++; return R; }

Compilation message (stderr)

taster.cpp: In function 'void sortA(std::vector<int>&)':
taster.cpp:8:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++) {
              ~^~~~~~~~~
taster.cpp: In function 'void sortB(std::vector<int>&, std::vector<int>&)':
taster.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++) R.push_back(-1);
              ~^~~~~~~~~
taster.cpp:19:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size();i++) {
              ~^~~~~~~~~
taster.cpp:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<V.size();j++) {
               ~^~~~~~~~~
taster.cpp: In function 'std::vector<int> SortWines(int, std::vector<int>)':
taster.cpp:56:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<hds.size();i++) {
              ~^~~~~~~~~~~
taster.cpp:59:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<val[T].size();j++) {
               ~^~~~~~~~~~~~~~
taster.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<val[i].size();j++) {
               ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...