답안 #935591

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935591 2024-02-29T09:35:58 Z Boycl07 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
39 ms 8352 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define FORD(i, n) for(int i = n - 1; i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "skycrapers"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)

void Anna(int N, std::vector<char> S);

void Send(int a);

const int Lim = 80;
const int LOG = 56;
ll f[Lim];

void precalc()
{
    f[0] = 1;
    f[1] = 2;
    for(int i = 2; i < Lim; ++i)
        f[i] = f[i - 1] + f[i - 2];
}

void Send_num(ll x)
{
    for(int i = 0; i <= LOG; ++i)
        if(x >> i & 1) Send(1);
    else Send(0);
}


void Anna(int n, vector<char> S)
{

    precalc();
    vector<int> res;
    bool flag = 0;
    int idx = 0;
    while(idx < n && S[idx] != 'X') res.pb(0), ++idx;
    if(idx != n) res.pb(1), ++idx;
    while(idx < n)
    {
        if(S[idx] != 'Z') res.pb(0), ++idx;
        else
        {
            res.pb(1);
            ++idx;
            while(idx < n && S[idx] == 'Z') ++idx;
        }
    }
    for(int i = 0; i < n; i += Lim)
    {

        ll cur = 0;
        forn(j, i, i + Lim)
            if(j < n) if(res[j]) cur += f[j - i];
        Send_num(cur);
    }
}



#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define FORD(i, n) for(int i = n - 1; i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "skycrapers"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)


void Bruno(int N, int L, std::vector<int> A);

void Remove(int d);

const int Lim_ = 80;
ll f_[Lim_];

void precalc_()
{
    f_[0] = 1;
    f_[1] = 2;
    for(int i = 2; i < Lim_; ++i)
        f_[i] = f_[i - 1] + f_[i - 2];
}



void decode(vector<int> &A)
{
    vector<int> res;
    for(int i = 0; i < sz(A); i += 56)
    {
        ll cur = 0;
        forn(j, 0, 56)
            if(A[i + j] == 1)
                cur |= 1 << j;
        vector<int> tmp;
        ford(j, 79, 0)
            if(cur >= f_[j]) tmp.pb(1), cur -= f_[j];
            else tmp.pb(0);
        reverse(all(tmp));
        for(int x : tmp) res.pb(x);
    }
    A = move(res);
}

void Bruno(int n, int Len, vector<int> A)
{
    precalc_();
    decode(A); while(sz(A) > n) A.pop_back();
    int first = 0;
    while(first < n && A[first] != 1)
        Remove(first++);
    if(first == n) return;
    for(int i = first + 1; i < n; ++i)
    {
        int j = i;
        while(j < n && A[j] != 1) ++j;
        ford(k, j - 1, i) Remove(k);
        if(j != n) Remove(j);
        i = j;
    }

    Remove(first);
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:52:10: warning: unused variable 'flag' [-Wunused-variable]
   52 |     bool flag = 0;
      |          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 780 KB Output is correct
2 Incorrect 0 ms 780 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 8352 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -