Submission #199000

# Submission time Handle Problem Language Result Execution time Memory
199000 2020-01-28T15:17:30 Z TadijaSebez Swap (BOI16_swap) C++11
0 / 100
6 ms 504 KB
#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]);
		assert(ans[i]>=1 && ans[i]<=n);
	}
	return 0;
}

Compilation message

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 time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -