Submission #198999

#TimeUsernameProblemLanguageResultExecution timeMemory
198999TadijaSebezSwap (BOI16_swap)C++11
0 / 100
5 ms256 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair const int inf=1e9+7; pair<int,int> min(pair<int,int> a,pair<int,int> b){return a<b?a:b;} int main(){ int n; scanf("%i",&n); vector<int> a(n*2+5,inf),ans(n+1); for(int i=1;i<=n;i++)scanf("%i",&a[i]); for(int i=1;i<=n;i++){ pair<int,int> mn=min(mp(a[i<<1],i<<1),mp(a[i<<1|1],i<<1|1)); int j=i; while(j){ mn=min(mn,mp(a[j],j)); if(j&1)mn=min(mn,mp(a[j^1],j^1)); j/=2; } ans[i]=mn.first; a[mn.second]=inf; printf("%i ",ans[i]); } return 0; }

Compilation message (stderr)

swap.cpp: In function 'int main()':
swap.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
swap.cpp:10:28: 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",&a[i]);
                       ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...