Submission #27109

# Submission time Handle Problem Language Result Execution time Memory
27109 2017-07-09T09:35:19 Z 윤교준(#1121) Swap (BOI16_swap) C++11
10 / 100
53 ms 4364 KB
#include <bits/stdc++.h>
#define MAXN (200005)
using namespace std;

int A[MAXN], B[MAXN], C[MAXN];
int N;

int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
	for(int i = 1; i <= N; i++) C[i] = A[i];
	for(int key = 0; key < (1<<(N-1)); key++) {
		for(int i = 1; i <= N; i++) B[i] = A[i];
		for(int i = 0; i < N-1; i++) if(key & (1<<i)) {
			swap(B[i+2], B[(i+2)/2]);
		}
		bool flag = false;
		for(int i = 1; i <= N; i++) {
			if(B[i] == C[i]) continue;
			if(B[i] > C[i]) break;
			flag = true; break;
		}
		if(!flag) continue;
		for(int i = 1; i <= N; i++) C[i] = B[i];
	}
	for(int i = 1; i <= N; i++) printf("%d ", C[i]);
	puts("");
	return 0;
}

Compilation message

swap.cpp: In function 'int main()':
swap.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
swap.cpp:10:48: 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("%d", &A[i]);
                                                ^
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4364 KB Output is correct
2 Correct 49 ms 4364 KB Output is correct
3 Correct 53 ms 4364 KB Output is correct
4 Correct 53 ms 4364 KB Output is correct
5 Correct 49 ms 4364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4364 KB Output is correct
2 Correct 49 ms 4364 KB Output is correct
3 Correct 53 ms 4364 KB Output is correct
4 Correct 53 ms 4364 KB Output is correct
5 Correct 49 ms 4364 KB Output is correct
6 Incorrect 0 ms 4364 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4364 KB Output is correct
2 Correct 49 ms 4364 KB Output is correct
3 Correct 53 ms 4364 KB Output is correct
4 Correct 53 ms 4364 KB Output is correct
5 Correct 49 ms 4364 KB Output is correct
6 Incorrect 0 ms 4364 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4364 KB Output is correct
2 Correct 49 ms 4364 KB Output is correct
3 Correct 53 ms 4364 KB Output is correct
4 Correct 53 ms 4364 KB Output is correct
5 Correct 49 ms 4364 KB Output is correct
6 Incorrect 0 ms 4364 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4364 KB Output is correct
2 Correct 49 ms 4364 KB Output is correct
3 Correct 53 ms 4364 KB Output is correct
4 Correct 53 ms 4364 KB Output is correct
5 Correct 49 ms 4364 KB Output is correct
6 Incorrect 0 ms 4364 KB Output isn't correct
7 Halted 0 ms 0 KB -