답안 #905270

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
905270 2024-01-12T21:46:51 Z MinaRagy06 The Collection Game (BOI21_swaps) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
#include "swaps.h"
#ifdef MINA
    #include "grader.cpp"
#endif
using namespace std;
typedef int64_t ll;

vector<array<int, 2>> ops[50];
int sz, n;
int bitonic(int l, int r, bool inc, int lvl) {
	if (l == r) {
		return lvl;
	}
	int md = (l + r) >> 1, mx;
	mx = bitonic(l, md, inc, lvl);
	bitonic(md + 1, r, !inc, lvl);
	for (int i = l; i <= md; i++) {
		int x = i, y = i + md + 1 - l;
		if (!inc) {
			ops[mx + 1].push_back({x, y});
		} else {
			ops[mx + 1].push_back({y, x});
		}
	}
	bitonic(l, md, inc, mx + 1);
	return bitonic(md + 1, r, inc, mx + 1);
}
void solve(int N, int v) {
	n = N;
	if (n == 1) {
		answer({1});
		return;
	}
	sz = 1 << (__lg(n - 1) + 1);
	vector<int> a(sz);
	for (int i = 0; i < sz; i++) {
		a[i] = i + 1;
	}
	int dep = bitonic(0, sz - 1, 1, -1);
	assert(dep < v);
    for (int j = 0; j < 50; j++) {
		if (ops[j].empty()) continue;
		for (auto [x, y] : ops[j]) {
			if (a[x] <= n && a[y] <= n) {
				schedule(a[x], a[y]);
			}
		}
		vector<int> ret = visit();
		int cnt = 0;
		for (auto [x, y] : ops[j]) {
			if (a[x] > n) {
				continue;
			}
			if (a[y] > n) {
				swap(a[x], a[y]);
				continue;
			}
			if (ret[cnt]) {
				swap(a[x], a[y]);
			}
			cnt++;
		}
	}
	while (a.size() > n) a.pop_back();
	answer(a);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:65:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |  while (a.size() > n) a.pop_back();
      |         ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -