답안 #546291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546291 2022-04-07T05:07:43 Z flappybird Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
22 ms 3792 KB
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 101010
#define B1 60
#define B2 42

namespace {
	vector<int> arr;
	vector<ll> fibo = { 2, 3 };
	vector<vector<int>> bukkit;
}

void Anna(int N, std::vector<char> S) {
	arr.resize(N);
	int i, c;
	c = 0;
	fibo.resize(B1);
	for (i = 2; i < B1; i++) fibo[i] = fibo[i - 1] + fibo[i - 2];
	for (i = 0; i < N; i++) {
		if (!c && S[i] == 'X') c = 1, arr[i] = 1;
		if (c && S[i] == 'Z') arr[i] = 1;
	}
	for (i = 1; i < N; i++) if (arr[i - 1] && arr[i]) arr[i - 1] = 0;
	bukkit.push_back(vector<int>());
	for (i = 0; i < N; i++) {
		if (bukkit.back().size() == B1) bukkit.push_back(vector<int>());
		bukkit.back().push_back(arr[i]);
	}
	bukkit.back().resize(B1);
	int bs = bukkit.size();
	ll res = 0;
	for (i = 0; i < bs; i++) {
		int j;
		for (j = 0; j < B1; j++) if (bukkit[i][j]) res += fibo[j];
		for (j = 0; j < B2; j++) {
			if (res & (1ll << (ll)j)) Send(1);
			else Send(0);
		}
	}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

namespace {
	const int B2 = 42;
	const int B1 = 60;
	vector<ll> fibo = { 2, 3 };
}  // namespace

void Bruno(int N, int L, std::vector<int> A) {
	int K = L / B2;
	int i;
	fibo.resize(B1);
	for (i = 2; i < B1; i++) fibo[i] = fibo[i - 1] + fibo[i - 2];
	vector<int> arr;
	for (i = 0; i < K; i++) {
		ll res = 0;
		ll j;
		for (j = 0; j < B2; j++) res += (ll)A[i * K + j] << (ll)j;
		vector<int> v;
		for (j = B1 - 1; j >= 0; j--) {
			if (res - fibo[j] >= 0) res -= fibo[j], v.push_back(1);
			else v.push_back(0);
		}
		reverse(v.begin(), v.end());
		for (auto x : v) arr.push_back(x);
	}
	arr.resize(N);
	vector<int> ones;
	int start = -1;
	for (i = 0; i < N; i++) {
		if (arr[i]) {
			start = i;
			break;
		}
	}
	if (start == -1) {
		for (i = 0; i < N; i++) Remove(i);
		return;
	}
	for (i = 0; i < N; i++) if (i != start && arr[i]) ones.push_back(i);
	if (ones.empty()) {
		for (i = 0; i < N; i++) Remove(i);
		return;
	}
	for (i = 0; i < start; i++) Remove(i);
	int pv = start;
	for (auto v : ones) {
		for (i = v - 1; i > pv; i--) Remove(i);
		Remove(v);
		pv = v;
	}
	Remove(start);
	for (i = pv + 1; i < N; i++) Remove(i);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 508 KB Output is correct
2 Incorrect 2 ms 596 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 3792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -