답안 #544761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544761 2022-04-02T16:31:10 Z rainboy The Collection Game (BOI21_swaps) C++14
100 / 100
12 ms 416 KB
#include "swaps.h"

using namespace std;

void solve(int n, int v) {
	vector<int> aa(n), ll(n), rr(n), lt;
	int m, h, i, j, l, l_, tmp;

	for (i = 0; i < n; i++)
		aa[i] = i + 1;
	for (l = 0; 1 << l < n; l++) {
		m = 1 << l + 1;
		for (i = 0; i < n; i++)
			if (i % m * 2 < m && (j = i - i % m * 2 + m - 1) < n)
				schedule(aa[i], aa[j]);
		lt = visit();
		for (i = 0, h = 0; i < n; i++)
			if (i % m * 2 < m && (j = i - i % m * 2 + m - 1) < n && !lt[h++])
				tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
		for (l_ = l - 1; l_ >= 0; l_--) {
			m = 1 << l_ + 1;
			for (i = 0; i < n; i++)
				if (i % m * 2 < m && (j = i + m / 2) < n)
					schedule(aa[i], aa[j]);
			lt = visit();
			for (i = 0, h = 0; i < n; i++)
				if (i % m * 2 < m && (j = i + m / 2) < n && !lt[h++])
					tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
		}
	}
	answer(aa);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:12:14: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   12 |   m = 1 << l + 1;
      |            ~~^~~
swaps.cpp:21:16: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   21 |    m = 1 << l_ + 1;
      |             ~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 292 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 6 ms 292 KB Correct
5 Correct 5 ms 296 KB Correct
6 Correct 5 ms 292 KB Correct
7 Correct 6 ms 288 KB Correct
8 Correct 5 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 5 ms 296 KB Correct
5 Correct 5 ms 416 KB Correct
6 Correct 6 ms 300 KB Correct
7 Correct 5 ms 296 KB Correct
8 Correct 5 ms 296 KB Correct
9 Correct 5 ms 300 KB Correct
10 Correct 6 ms 292 KB Correct
11 Correct 7 ms 288 KB Correct
12 Correct 7 ms 296 KB Correct
13 Correct 5 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 1 ms 208 KB Correct
4 Correct 1 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 11 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 11 ms 300 KB Correct
5 Correct 1 ms 208 KB Correct
6 Correct 1 ms 288 KB Correct
7 Correct 2 ms 208 KB Correct
8 Correct 5 ms 296 KB Correct
9 Correct 5 ms 296 KB Correct
10 Correct 4 ms 296 KB Correct
11 Correct 5 ms 400 KB Correct
12 Correct 5 ms 400 KB Correct
13 Correct 1 ms 208 KB Correct
14 Correct 2 ms 208 KB Correct
15 Correct 3 ms 280 KB Correct
16 Correct 5 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 5 ms 296 KB Correct
5 Correct 6 ms 268 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 5 ms 296 KB Correct
5 Correct 6 ms 268 KB Correct
6 Correct 1 ms 208 KB Correct
7 Correct 1 ms 208 KB Correct
8 Correct 2 ms 208 KB Correct
9 Correct 7 ms 296 KB Correct
10 Correct 7 ms 296 KB Correct
11 Correct 7 ms 296 KB Correct
12 Correct 5 ms 300 KB Correct
13 Correct 5 ms 296 KB Correct
14 Correct 7 ms 296 KB Correct
15 Correct 5 ms 296 KB Correct
16 Correct 7 ms 292 KB Correct
17 Correct 6 ms 296 KB Correct
18 Correct 6 ms 296 KB Correct
19 Correct 0 ms 208 KB Correct
20 Correct 1 ms 280 KB Correct
21 Correct 3 ms 208 KB Correct
22 Correct 5 ms 296 KB Correct
23 Correct 5 ms 276 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 276 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 11 ms 208 KB Correct
5 Correct 5 ms 276 KB Correct
6 Correct 5 ms 260 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 276 KB Correct
3 Correct 2 ms 208 KB Correct
4 Correct 11 ms 208 KB Correct
5 Correct 5 ms 276 KB Correct
6 Correct 5 ms 260 KB Correct
7 Correct 1 ms 208 KB Correct
8 Correct 1 ms 288 KB Correct
9 Correct 3 ms 208 KB Correct
10 Correct 7 ms 296 KB Correct
11 Correct 5 ms 292 KB Correct
12 Correct 6 ms 292 KB Correct
13 Correct 7 ms 292 KB Correct
14 Correct 10 ms 296 KB Correct
15 Correct 12 ms 208 KB Correct
16 Correct 7 ms 292 KB Correct
17 Correct 5 ms 296 KB Correct
18 Correct 5 ms 292 KB Correct
19 Correct 5 ms 296 KB Correct
20 Correct 0 ms 208 KB Correct
21 Correct 1 ms 208 KB Correct
22 Correct 6 ms 208 KB Correct
23 Correct 6 ms 296 KB Correct
24 Correct 6 ms 272 KB Correct
25 Correct 6 ms 280 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 276 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 296 KB Correct
5 Correct 5 ms 276 KB Correct
6 Correct 7 ms 276 KB Correct
7 Correct 5 ms 276 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 276 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 3 ms 208 KB Correct
4 Correct 5 ms 296 KB Correct
5 Correct 5 ms 276 KB Correct
6 Correct 7 ms 276 KB Correct
7 Correct 5 ms 276 KB Correct
8 Correct 0 ms 208 KB Correct
9 Correct 1 ms 208 KB Correct
10 Correct 2 ms 208 KB Correct
11 Correct 3 ms 208 KB Correct
12 Correct 5 ms 292 KB Correct
13 Correct 5 ms 296 KB Correct
14 Correct 7 ms 304 KB Correct
15 Correct 5 ms 316 KB Correct
16 Correct 5 ms 296 KB Correct
17 Correct 7 ms 300 KB Correct
18 Correct 6 ms 292 KB Correct
19 Correct 5 ms 296 KB Correct
20 Correct 5 ms 292 KB Correct
21 Correct 5 ms 296 KB Correct
22 Correct 1 ms 208 KB Correct
23 Correct 5 ms 208 KB Correct
24 Correct 5 ms 208 KB Correct
25 Correct 7 ms 296 KB Correct
26 Correct 5 ms 280 KB Correct
27 Correct 5 ms 284 KB Correct
28 Correct 7 ms 280 KB Correct