Submission #510050

# Submission time Handle Problem Language Result Execution time Memory
510050 2022-01-14T15:15:08 Z Elegia The Collection Game (BOI21_swaps) C++17
100 / 100
6 ms 412 KB
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
//     swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <vector>
#include <algorithm>
#include <numeric>
#include "swaps.h"

using namespace std;

void solve(int N, int V) {
	vector<int> ans(N); iota(ans.begin(), ans.end(), 1);
	for (int p = 1; p < N; p *= 2)
		for (int k = p; k; k /= 2) {
			for (int j = k % p; j <= N - k - 1; j += k * 2)
				for (int i = 0; i <= min(k - 1, N - j - k - 1); ++i)
					if ((i + j) / (p * 2) == (i + j + k) / (p * 2))
						schedule(ans[i + j], ans[i + j + k]);
			vector<int> res = visit(); int cnt = 0;
			for (int j = k % p; j <= N - k - 1; j += k * 2)
				for (int i = 0; i <= min(k - 1, N - j - k - 1); ++i)
					if ((i + j) / (p * 2) == (i + j + k) / (p * 2))
						if (!res[cnt++]) swap(ans[i + j], ans[i + j + k]);
		}
	answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 2 ms 200 KB Correct
4 Correct 5 ms 288 KB Correct
5 Correct 4 ms 292 KB Correct
6 Correct 3 ms 292 KB Correct
7 Correct 4 ms 284 KB Correct
8 Correct 4 ms 292 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 2 ms 276 KB Correct
4 Correct 4 ms 284 KB Correct
5 Correct 5 ms 288 KB Correct
6 Correct 4 ms 340 KB Correct
7 Correct 4 ms 292 KB Correct
8 Correct 3 ms 288 KB Correct
9 Correct 4 ms 296 KB Correct
10 Correct 4 ms 288 KB Correct
11 Correct 5 ms 280 KB Correct
12 Correct 4 ms 272 KB Correct
13 Correct 4 ms 292 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 0 ms 200 KB Correct
4 Correct 1 ms 200 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 272 KB Correct
3 Correct 2 ms 272 KB Correct
4 Correct 4 ms 280 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 272 KB Correct
3 Correct 2 ms 272 KB Correct
4 Correct 4 ms 280 KB Correct
5 Correct 0 ms 200 KB Correct
6 Correct 1 ms 200 KB Correct
7 Correct 2 ms 200 KB Correct
8 Correct 4 ms 392 KB Correct
9 Correct 5 ms 288 KB Correct
10 Correct 5 ms 288 KB Correct
11 Correct 4 ms 268 KB Correct
12 Correct 3 ms 288 KB Correct
13 Correct 0 ms 200 KB Correct
14 Correct 1 ms 200 KB Correct
15 Correct 2 ms 200 KB Correct
16 Correct 4 ms 256 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 268 KB Correct
3 Correct 2 ms 200 KB Correct
4 Correct 4 ms 284 KB Correct
5 Correct 5 ms 268 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 268 KB Correct
3 Correct 2 ms 200 KB Correct
4 Correct 4 ms 284 KB Correct
5 Correct 5 ms 268 KB Correct
6 Correct 1 ms 264 KB Correct
7 Correct 1 ms 200 KB Correct
8 Correct 2 ms 200 KB Correct
9 Correct 4 ms 288 KB Correct
10 Correct 3 ms 292 KB Correct
11 Correct 4 ms 296 KB Correct
12 Correct 5 ms 288 KB Correct
13 Correct 6 ms 292 KB Correct
14 Correct 4 ms 252 KB Correct
15 Correct 4 ms 288 KB Correct
16 Correct 4 ms 288 KB Correct
17 Correct 4 ms 292 KB Correct
18 Correct 4 ms 296 KB Correct
19 Correct 0 ms 200 KB Correct
20 Correct 1 ms 200 KB Correct
21 Correct 2 ms 244 KB Correct
22 Correct 4 ms 292 KB Correct
23 Correct 4 ms 256 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 2 ms 280 KB Correct
4 Correct 4 ms 288 KB Correct
5 Correct 4 ms 268 KB Correct
6 Correct 6 ms 248 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 2 ms 280 KB Correct
4 Correct 4 ms 288 KB Correct
5 Correct 4 ms 268 KB Correct
6 Correct 6 ms 248 KB Correct
7 Correct 0 ms 276 KB Correct
8 Correct 1 ms 200 KB Correct
9 Correct 3 ms 200 KB Correct
10 Correct 5 ms 288 KB Correct
11 Correct 4 ms 292 KB Correct
12 Correct 4 ms 292 KB Correct
13 Correct 3 ms 288 KB Correct
14 Correct 5 ms 292 KB Correct
15 Correct 4 ms 292 KB Correct
16 Correct 4 ms 292 KB Correct
17 Correct 5 ms 324 KB Correct
18 Correct 4 ms 288 KB Correct
19 Correct 4 ms 292 KB Correct
20 Correct 1 ms 200 KB Correct
21 Correct 1 ms 200 KB Correct
22 Correct 2 ms 200 KB Correct
23 Correct 4 ms 296 KB Correct
24 Correct 4 ms 268 KB Correct
25 Correct 4 ms 256 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 272 KB Correct
3 Correct 2 ms 200 KB Correct
4 Correct 4 ms 292 KB Correct
5 Correct 4 ms 272 KB Correct
6 Correct 4 ms 252 KB Correct
7 Correct 4 ms 256 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Correct
2 Correct 1 ms 272 KB Correct
3 Correct 2 ms 200 KB Correct
4 Correct 4 ms 292 KB Correct
5 Correct 4 ms 272 KB Correct
6 Correct 4 ms 252 KB Correct
7 Correct 4 ms 256 KB Correct
8 Correct 0 ms 200 KB Correct
9 Correct 0 ms 200 KB Correct
10 Correct 1 ms 200 KB Correct
11 Correct 2 ms 248 KB Correct
12 Correct 3 ms 292 KB Correct
13 Correct 5 ms 288 KB Correct
14 Correct 4 ms 288 KB Correct
15 Correct 4 ms 292 KB Correct
16 Correct 5 ms 276 KB Correct
17 Correct 4 ms 292 KB Correct
18 Correct 6 ms 412 KB Correct
19 Correct 6 ms 292 KB Correct
20 Correct 5 ms 280 KB Correct
21 Correct 4 ms 288 KB Correct
22 Correct 0 ms 272 KB Correct
23 Correct 1 ms 200 KB Correct
24 Correct 2 ms 200 KB Correct
25 Correct 5 ms 276 KB Correct
26 Correct 6 ms 268 KB Correct
27 Correct 6 ms 252 KB Correct
28 Correct 4 ms 252 KB Correct