Submission #959763

# Submission time Handle Problem Language Result Execution time Memory
959763 2024-04-09T03:59:31 Z josanneo22 The Collection Game (BOI21_swaps) C++17
10 / 100
26 ms 700 KB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define rep(i, n) L(i, 1, n)
#define all(x) x.begin(),x.end()
#define me(x,a) memset(x,a,sizeof(x))

#include<random>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      
#include "swaps.h"

const int nax = 505;
int a[nax];

void N2(int N, int V) {
	L(i, 1, N) a[i] = i;
	L(i, 1, N) L(j, i + 1, N) {
		schedule(a[i], a[j]);
		vector<int> res = visit();
		if (res[0] == 0) swap(a[i], a[j]);
	}
	vector<int> ans;
	L(i, 1, N) ans.push_back(a[i]);
	answer(ans);
	return;
}

void merge(int l, int r) {
	if (l == r) return;
	int mid = (l + r) >> 1;
	merge(l, mid); merge(mid + 1, r);
	int LP = l, RP = mid + 1;
	vector<int> T;
	while (1) {
		if (LP <= mid && RP <= r) {
			schedule(a[LP], a[RP]);
			vector<int> res = visit();
			if (res[0] == 1) {
				T.push_back(a[LP]);
				LP++;
			}
			else {
				T.push_back(a[RP]);
				RP++;
			}
		}
		else if (LP == mid + 1 && RP <= r) {
			T.push_back(a[RP]);
			RP++;
		}
		else if (LP <= mid && RP == r + 1) {
			T.push_back(a[LP]);
			LP++;
		}
		if (LP == mid + 1 && RP == r + 1) break;
	}
	L(i, l, r) a[i] = T[i - l];
}
void merge_sol(int N, int V) {
	L(i, 1, N) a[i] = i;
	merge(1, N);
	vector<int> ans;
	L(i, 1, N) ans.push_back(a[i]);
	answer(ans);
	return;
}
void odd_even(int N,int V) {
	L(i, 1, N) a[i] = i;
	int par = 1;
	for (int t = 0; t < N; t++) {
		int st = 1 + (par == 1);
		vector<pair<int,int>> q;
		for (int i = st; i + 1 <= N; i += 2) {
			schedule(a[st], a[st + 1]);
			q.push_back(make_pair(st, st + 1));
		}
		vector<int> res = visit();
		for (int i = 0; i < (int)res.size(); i++) {
			if (res[i] == 0) {
				swap(a[q[i].first], a[q[i].second]);
			}
		}
		par ^= 1;
	}
	vector<int> ans;
	L(i, 1, N) ans.push_back(a[i]);
	answer(ans);
	return;
}
void solve(int N, int V) {
	int costN_2 = 0;
	L(i, 1, N) L(j, i + 1, N) costN_2++;
	if (costN_2 <= V) N2(N, V);
	if (N <= 500 && N * 9 <= V) merge_sol(N, V);
	odd_even(N, V);
	return;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 24 ms 344 KB Correct
3 Correct 8 ms 448 KB Correct
4 Correct 23 ms 440 KB Correct
5 Correct 12 ms 444 KB Correct
6 Correct 9 ms 604 KB Correct
7 Correct 18 ms 444 KB Correct
8 Correct 17 ms 444 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 23 ms 344 KB Correct
3 Correct 9 ms 444 KB Correct
4 Correct 17 ms 440 KB Correct
5 Correct 11 ms 448 KB Correct
6 Correct 12 ms 440 KB Correct
7 Correct 16 ms 448 KB Correct
8 Correct 16 ms 700 KB Correct
9 Incorrect 0 ms 344 KB Not correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 23 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 23 ms 344 KB Correct
3 Correct 0 ms 344 KB Correct
4 Correct 24 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 23 ms 344 KB Correct
3 Incorrect 4 ms 440 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 23 ms 344 KB Correct
3 Incorrect 4 ms 440 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 26 ms 344 KB Correct
3 Incorrect 5 ms 600 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 26 ms 344 KB Correct
3 Incorrect 5 ms 600 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 23 ms 344 KB Correct
3 Incorrect 6 ms 448 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 23 ms 344 KB Correct
3 Incorrect 6 ms 448 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 21 ms 344 KB Correct
3 Incorrect 4 ms 440 KB Not correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 21 ms 344 KB Correct
3 Incorrect 4 ms 440 KB Not correct
4 Halted 0 ms 0 KB -