Submission #935626

# Submission time Handle Problem Language Result Execution time Memory
935626 2024-02-29T09:55:48 Z Boycl07 Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
43 ms 8168 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 = 83;
const int LOG = 57;
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;
    int idx = 0;
    while(idx < n && S[idx] != 'X') res.pb(0), ++idx;
    int pos = 0;
    if(idx != n)
    {
        res.pb(1), ++idx;
        pos = idx;
    }
    int flag = 0;
    while(idx < n)
    {
        if(S[idx] != 'Z') res.pb(0), ++idx;
        else
        {

            if(res.back() == 1)
            {
                res.pb(0);
                flag = 1;
            }
            else res.pb(1);
            ++idx;
            while(idx < n && S[idx] == 'Z') ++idx, res.pb(0);
        }
    }
    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);
    }

    Send(flag);

}



#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_ = 83;
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 += 58)
    {
        ll cur = 0;
        forn(j, 0, 57)
            if(A[i + j] == 1)
                cur |= 1 << j;
        vector<int> tmp;
        ford(j, 82, 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_();
    bool flag = A.back(); A.pop_back();
    decode(A); while(sz(A) > n) A.pop_back();
    int first = 0;
    while(first < n && A[first] != 1)
        Remove(first++);
    if(first == n) return;
    if(flag) A[first + 1] = 1;
    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:54:9: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
   54 |     int pos = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 792 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 8168 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -