답안 #427983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427983 2021-06-15T06:39:09 Z patrikpavic2 The Collection Game (BOI21_swaps) C++17
100 / 100
8 ms 508 KB
#include "swaps.h"
#include <vector>
#include <algorithm>
#include <cstdio>

#define X first
#define Y second
#define PB push_back
#define EB emplace_back

using namespace std;

typedef vector < int > vi;
typedef pair < int, int > pii;

void solve(int n, int v) {
	int lg2 = 8;
	vector < int > P;
	vector < pii > tko;
	for(int i = 1;i <= n;i++) P.PB(i);
	for(int i = 0;i <= lg2;i++){
		for(int j = i;j >= 0;j--){
			for(int k = 0;k < n;k++){
				if(i != j && (k & (1 << j))){
					tko.EB(k ^ (1 << j), k);
					schedule(P[tko.back().X], P[tko.back().Y]);
				}
				if(i == j && (k ^ ((1 << (j + 1)) - 1)) < k){
					tko.EB(k ^ ((1 << (j + 1)) - 1), k);
					schedule(P[tko.back().X], P[tko.back().Y]);
				}	
			}
			vi odg = visit();
			for(int i = 0;i < (int)odg.size();i++)
				if(!odg[i]) swap(P[tko[i].X], P[tko[i].Y]);
			tko.clear();	
		}
	}
	answer(P);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 268 KB Correct
2 Correct 3 ms 328 KB Correct
3 Correct 4 ms 200 KB Correct
4 Correct 7 ms 292 KB Correct
5 Correct 7 ms 288 KB Correct
6 Correct 6 ms 288 KB Correct
7 Correct 7 ms 288 KB Correct
8 Correct 5 ms 288 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 280 KB Correct
3 Correct 4 ms 200 KB Correct
4 Correct 7 ms 288 KB Correct
5 Correct 5 ms 288 KB Correct
6 Correct 5 ms 288 KB Correct
7 Correct 7 ms 288 KB Correct
8 Correct 7 ms 280 KB Correct
9 Correct 5 ms 288 KB Correct
10 Correct 6 ms 508 KB Correct
11 Correct 5 ms 288 KB Correct
12 Correct 5 ms 284 KB Correct
13 Correct 8 ms 496 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 3 ms 328 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 3 ms 328 KB Correct
3 Correct 1 ms 200 KB Correct
4 Correct 2 ms 280 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 6 ms 288 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 6 ms 288 KB Correct
5 Correct 2 ms 200 KB Correct
6 Correct 2 ms 200 KB Correct
7 Correct 3 ms 200 KB Correct
8 Correct 6 ms 292 KB Correct
9 Correct 5 ms 284 KB Correct
10 Correct 7 ms 284 KB Correct
11 Correct 5 ms 292 KB Correct
12 Correct 7 ms 292 KB Correct
13 Correct 1 ms 200 KB Correct
14 Correct 2 ms 200 KB Correct
15 Correct 5 ms 200 KB Correct
16 Correct 6 ms 288 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 5 ms 200 KB Correct
4 Correct 6 ms 288 KB Correct
5 Correct 5 ms 284 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 5 ms 200 KB Correct
4 Correct 6 ms 288 KB Correct
5 Correct 5 ms 284 KB Correct
6 Correct 1 ms 200 KB Correct
7 Correct 2 ms 200 KB Correct
8 Correct 4 ms 200 KB Correct
9 Correct 7 ms 352 KB Correct
10 Correct 5 ms 284 KB Correct
11 Correct 6 ms 288 KB Correct
12 Correct 5 ms 288 KB Correct
13 Correct 6 ms 288 KB Correct
14 Correct 6 ms 292 KB Correct
15 Correct 7 ms 284 KB Correct
16 Correct 5 ms 288 KB Correct
17 Correct 6 ms 288 KB Correct
18 Correct 6 ms 284 KB Correct
19 Correct 1 ms 200 KB Correct
20 Correct 2 ms 276 KB Correct
21 Correct 4 ms 200 KB Correct
22 Correct 5 ms 280 KB Correct
23 Correct 7 ms 268 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 4 ms 200 KB Correct
4 Correct 7 ms 288 KB Correct
5 Correct 6 ms 268 KB Correct
6 Correct 5 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 4 ms 200 KB Correct
4 Correct 7 ms 288 KB Correct
5 Correct 6 ms 268 KB Correct
6 Correct 5 ms 348 KB Correct
7 Correct 1 ms 200 KB Correct
8 Correct 2 ms 200 KB Correct
9 Correct 3 ms 200 KB Correct
10 Correct 5 ms 284 KB Correct
11 Correct 5 ms 292 KB Correct
12 Correct 5 ms 288 KB Correct
13 Correct 6 ms 288 KB Correct
14 Correct 6 ms 292 KB Correct
15 Correct 5 ms 284 KB Correct
16 Correct 5 ms 284 KB Correct
17 Correct 8 ms 284 KB Correct
18 Correct 6 ms 284 KB Correct
19 Correct 5 ms 284 KB Correct
20 Correct 2 ms 200 KB Correct
21 Correct 2 ms 200 KB Correct
22 Correct 3 ms 200 KB Correct
23 Correct 6 ms 364 KB Correct
24 Correct 6 ms 288 KB Correct
25 Correct 7 ms 264 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 7 ms 284 KB Correct
5 Correct 5 ms 264 KB Correct
6 Correct 7 ms 268 KB Correct
7 Correct 5 ms 264 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 7 ms 284 KB Correct
5 Correct 5 ms 264 KB Correct
6 Correct 7 ms 268 KB Correct
7 Correct 5 ms 264 KB Correct
8 Correct 1 ms 200 KB Correct
9 Correct 1 ms 200 KB Correct
10 Correct 2 ms 200 KB Correct
11 Correct 3 ms 200 KB Correct
12 Correct 5 ms 284 KB Correct
13 Correct 6 ms 288 KB Correct
14 Correct 5 ms 284 KB Correct
15 Correct 7 ms 284 KB Correct
16 Correct 6 ms 284 KB Correct
17 Correct 7 ms 284 KB Correct
18 Correct 5 ms 280 KB Correct
19 Correct 5 ms 292 KB Correct
20 Correct 7 ms 280 KB Correct
21 Correct 6 ms 288 KB Correct
22 Correct 1 ms 200 KB Correct
23 Correct 2 ms 200 KB Correct
24 Correct 3 ms 200 KB Correct
25 Correct 5 ms 288 KB Correct
26 Correct 6 ms 264 KB Correct
27 Correct 5 ms 264 KB Correct
28 Correct 6 ms 272 KB Correct