Submission #63397

#TimeUsernameProblemLanguageResultExecution timeMemory
63397rzbtZalmoxis (BOI18_zalmoxis)C++14
5 / 100
1098 ms62724 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 1000006 using namespace std; int n,k; int l[MAXN],d[MAXN],niz[MAXN]; int orig[MAXN]; vector<int> gde[MAXN]; int main() { scanf("%d %d", &n, &k); for(int i=1;i<=n;i++){ scanf("%d",niz+i); orig[i]=niz[i]; l[i]=i; d[i]=i; } for(int j=1;j<30;j++){ for(int i=1;i<=n;i++){ if(!niz[i] || niz[i]!=j)continue; if(niz[i]==niz[d[i]+1]){ niz[d[i]+1]=0; niz[i]++; d[i]=d[d[i]+1]; }else{ gde[d[i]].pb(j); niz[i]++; k--; } i=d[i]; } } for(int i=1;i<=n;i++){ printf("%d ",orig[i]); if(k==0){ for(auto x:gde[i])printf("%d ",x); continue; } reverse(all(gde[i])); while(!gde[i].empty()){ if(k==0 || gde[i].back()==1){ printf("%d ",gde[i].back()); gde[i].pop_back(); }else{ k--; int nzm=gde[i].back()-1; gde[i].pop_back(); gde[i].pb(nzm);gde[i].pb(nzm); } } } return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
zalmoxis.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",niz+i);
         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...