답안 #398677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
398677 2021-05-04T17:12:06 Z egorlifar The Collection Game (BOI21_swaps) C++17
15 / 100
15 ms 500 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 "swaps.h"
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double; 
const string FILENAME = "input";


const int MAXN = 2005;
vector<pair<int, vector<int> > > who[MAXN];
vector<int> ans[MAXN];


void preparestor(int v, vector<int> vals, int deep) {
	if (sz(vals) <= 1) {
		ans[v] = vals;
		return;
	}
	vector<int> vals1, vals2;
	for (int i = 0; i < sz(vals) / 2; i++) {
		vals1.pb(vals[i]);
	}
	for (int i = sz(vals) / 2; i < sz(vals); i++) {
		vals2.pb(vals[i]);
	}
	preparestor(v * 2, vals1, deep + 1);
	preparestor(v * 2 + 1, vals2, deep + 1);
	who[deep].pb(mp(v, vals));
}



int uk[MAXN];
int uk1[MAXN];


void solve(int n, int v) {
	vector<int> vals;
	for (int i = 1; i <= n; i++) {
		vals.pb(i);
	}
	preparestor(1, vals, 0);
	for (int f = 30; f >= 0; f--) {
		if (!who[f].empty()) {
			for (int j = 0; j < sz(who[f]); j++) {
				uk[j] = 0;
				uk1[j] = 0;
			}
			while (true) {
				bool was = false;
				vector<int> st;
				for (int j = 0; j < sz(who[f]); j++) {
					int v = who[f][j].first;
					if (uk[j] == sz(ans[v * 2])) {
						while (uk1[j] < sz(ans[v * 2 + 1])) {
							ans[v].pb(ans[v * 2 + 1][uk1[j]]);
							uk1[j]++;
						}
						continue;
					}
					if (uk1[j] == sz(ans[v * 2 + 1])) {
						while (uk[j] < sz(ans[v * 2])) {
							ans[v].pb(ans[v * 2][uk[j]]);
							uk[j]++;
						}
						continue;
					}
					was = true;
					schedule(ans[v * 2][uk[j]], ans[v * 2 + 1][uk1[j]]);
					st.pb(j);
				}
				if (was) {
					auto ff = visit();
					int fk = 0;
					for (auto x: st) {
						int v = who[f][x].first;
						if (ff[fk]) {
							ans[v].pb(ans[v * 2][uk[x]]);
							uk[x]++; 
						} else {
							ans[v].pb(ans[v * 2 + 1][uk1[x]]);
							uk1[x]++;
						}
						fk++;
					}
				} else {
					break;
				}
			}
		}
	}
	answer(ans[1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Correct
2 Correct 3 ms 328 KB Correct
3 Correct 8 ms 328 KB Correct
4 Correct 7 ms 496 KB Correct
5 Correct 7 ms 456 KB Correct
6 Correct 8 ms 500 KB Correct
7 Correct 10 ms 496 KB Correct
8 Correct 15 ms 456 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Correct
2 Correct 4 ms 328 KB Correct
3 Correct 8 ms 328 KB Correct
4 Correct 14 ms 456 KB Correct
5 Correct 8 ms 456 KB Correct
6 Correct 8 ms 492 KB Correct
7 Correct 14 ms 492 KB Correct
8 Correct 14 ms 456 KB Correct
9 Correct 12 ms 468 KB Correct
10 Correct 6 ms 492 KB Correct
11 Correct 5 ms 492 KB Correct
12 Correct 9 ms 456 KB Correct
13 Correct 14 ms 456 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 328 KB Not correct
2 Halted 0 ms 0 KB -