답안 #199034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199034 2020-01-28T17:31:59 Z TadijaSebez Swap (BOI16_swap) C++11
0 / 100
5 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
const int inf=1e9+7;
int main(){
	int n;
	scanf("%i",&n);
	vector<int> a(n*2+5,inf),ans(n+1);
	vector<bool> rsv(n+1,0);
	for(int i=1;i<=n;i++)scanf("%i",&a[i]);
	for(int i=1;i<=n;i++){
		if(rsv[i])swap(a[i>>1],a[i]);
		int ch=i<<1|1;
		if(a[i<<1]<a[i<<1|1])ch=i<<1;
		if(rsv[i^1] && a[i>>1]<a[ch])ch=i>>1;
		if(a[ch]<a[i]){
			if(ch>i && (ch&1))rsv[ch]=1;
			else if(ch<i)swap(a[i],a[ch]);
			else swap(a[i],a[ch]);
		}
	}
	for(int i=1;i<=n;i++)printf("%i ",a[i]);printf("\n");
	return 0;
}

Compilation message

swap.cpp: In function 'int main()':
swap.cpp:23:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=1;i<=n;i++)printf("%i ",a[i]);printf("\n");
  ^~~
swap.cpp:23:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=1;i<=n;i++)printf("%i ",a[i]);printf("\n");
                                          ^~~~~~
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:11: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]);
                       ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -