Submission #587187

# Submission time Handle Problem Language Result Execution time Memory
587187 2022-07-01T13:00:29 Z M_W Swap (BOI16_swap) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#define ar array<int, 3>
using namespace std;
int a[200002];

ar find_min(int a, int b, int c){
	vector<ar> tmp;
	tmp.push_back({a, b, c});
	tmp.push_back({b, a, c});
	tmp.push_back({c, a, b});
	tmp.push_back({c, b, a});
	sort(tmp.begin(), tmp.end());
	return tmp[0];
}

int main(){
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", &a[i]);
	for(int i = 1; i * 2 <= N; i++){
		ar tmp;
		if(i * 2 + 1 > N) tmp = find_min(a[i], a[i * 2], max(a[i], a[i * 2]));
		else tmp = find_min(a[i], a[i * 2], a[i * 2 + 1]);
		
		a[i] = tmp[0]; a[i * 2] = tmp[1]; a[i * 2 + 1] = tmp[2];
	}
	for(int i = 1; i <= N; i++) printf("%d ", a[i]);
}

Compilation message

swap.cpp: In function 'int main()':
swap.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
swap.cpp:19:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  for(int i = 1; i <= N; i++) scanf("%d", &a[i]);
      |                              ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -