Submission #861928

#TimeUsernameProblemLanguageResultExecution timeMemory
861928AiperiiiZalmoxis (BOI18_zalmoxis)C++14
0 / 100
1076 ms19744 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(),x.end() #define ff first #define ss second int cnt[40]; int val=-1; vector <int> res; void dfs(int v){ bool flag=false; for(int i=0;i<v;i++){ if(cnt[i]!=0){ flag=true; } } if(!flag){ val=v; res.push_back(v); return; } else{ if(cnt[v-1]==1){ res.push_back(v-1); cnt[v-1]--; dfs(v-1); } else if(cnt[v-1]==0){ dfs(v-1); dfs(v-1); } else if(cnt[v-1]==2){ res.push_back(v-1); res.push_back(v-1); cnt[v-1]=0; } } } signed main(){ freopen("zalmoxis.in","r",stdin); freopen("zalmoxis.out","w",stdout); int n,k; cin>>n>>k; vector <int> a(n); for(int i=0;i<n;i++){ cin>>a[i]; cnt[a[i]]++; } dfs(30); for(auto i : res)cout<<i<<" "; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:41:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     freopen("zalmoxis.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
zalmoxis.cpp:42:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     freopen("zalmoxis.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...