Submission #642509

#TimeUsernameProblemLanguageResultExecution timeMemory
642509Tenis0206Devil's Share (RMI19_devil)C++11
100 / 100
455 ms5168 KiB
#include <bits/stdc++.h> using namespace std; int k; vector<string> v; queue<string> q; int fr[15]; int get_max() { for(int c=9; c>=1; c--) { if(fr[c]) { return c; } } } void solve_test() { cin>>k; for(int i=1; i<=9; i++) { cin>>fr[i]; } string rez; for(int i=1; i<k; i++) { rez.push_back(get_max() + '0'); --fr[get_max()]; } reverse(rez.begin(),rez.end()); int Max = get_max(); for(int i=1; i<=fr[Max]; i++) { string aux; aux.push_back(Max + '0'); v.push_back(aux); } for(int c=1; c<Max; c++) { for(int i=1; i<=fr[c]; i++) { string aux; aux.push_back(c + '0'); q.push(aux); } } int poz = v.size() - 1; while(!q.empty()) { string s = q.front(); q.pop(); v[poz] += s; --poz; if(poz < 0) { poz = v.size() - 1; } else if(q.empty() || s!=q.front()) { while(v.size()-1 > poz) { q.push(v.back()); v.pop_back(); } } } for(int i=v.size()-1; i>=0; i--) { rez = v[i] + rez; } v.clear(); cout<<rez<<'\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin>>t; for(int test=1; test<=t; test++) { solve_test(); } return 0; }

Compilation message (stderr)

devil.cpp: In function 'void solve_test()':
devil.cpp:66:30: warning: comparison of integer expressions of different signedness: 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |             while(v.size()-1 > poz)
      |                   ~~~~~~~~~~~^~~~~
devil.cpp: In function 'int get_max()':
devil.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...