Submission #144996

#TimeUsernameProblemLanguageResultExecution timeMemory
144996MKopchevZalmoxis (BOI18_zalmoxis)C++14
100 / 100
208 ms14432 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=1e6+42; int n,k; int inp[nmax]; vector<int> sequence,output; int pos=1; void go(int num) { if(pos>n||inp[pos]>num) { sequence.push_back(num); return; } if(inp[pos]==num) { pos++; sequence.push_back(num); return; } go(num-1); go(num-1); } int sz_now; void expand(int num) { //cout<<"expand "<<num<<" "<<sz_now<<endl; if(num==0||sz_now==n+k) { output.push_back(num); return; } sz_now++; expand(num-1); expand(num-1); } int main() { scanf("%i%i",&n,&k); for(int i=1;i<=n;i++)scanf("%i",&inp[i]); go(30); pos=1; sz_now=sequence.size(); for(int i=0;i<sequence.size();i++) { if(pos<=n&&sequence[i]==inp[pos]) { output.push_back(sequence[i]); pos++; continue; } expand(sequence[i]); } assert(output.size()==n+k); for(auto p:output) printf("%i ",p); return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:51:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<sequence.size();i++)
                 ~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from zalmoxis.cpp:1:
zalmoxis.cpp:62:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     assert(output.size()==n+k);
            ~~~~~~~~~~~~~^~~~~
zalmoxis.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
zalmoxis.cpp:43:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++)scanf("%i",&inp[i]);
                          ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...