Submission #592541

# Submission time Handle Problem Language Result Execution time Memory
592541 2022-07-09T09:48:16 Z cheissmart Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
7 ms 852 KB
#include "Anna.h"
#include <vector>
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

namespace {
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
    cerr << to_string(h);
    if(sizeof ...(t)) cerr << ", ";
    DBG(t...);
}
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

const int INF = 1e9 + 7;

ll fib[70];

}

void Anna(int n, V<char> s) {
    int pos = n - 1;
    for(int i = 0; i < n; i++)
        if(s[i] == 'X') {
            pos = i;
            break;
        }
    for(int i = 0; i < 17; i++)
        Send(pos >> i & 1);

    V<bool> he(n);
    for(int i = pos + 1; i < n; i++)
        if(s[i] == 'Z' && (i + 1 >= n || s[i + 1] != 'Z'))
            he[i] = true;

    fib[0] = fib[1] = 2;
    for(int i = 2; i < 70; i++)
        fib[i] = fib[i - 1] + fib[i - 2];

    for(int i = 0; i < n; i += 70) {
        ll tt = 0;
        for(int j = i; j < n && j < i + 70; j++)
            tt += he[j] * fib[j - i];
        assert(tt < (1LL << 48));
        for(int j = 0; j < 48; j++)
            Send(tt >> j & 1);
    }

}
#include "Bruno.h"
#include <vector>
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

namespace {
string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
    cerr << to_string(h);
    if(sizeof ...(t)) cerr << ", ";
    DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7;

ll fib[70];

}

void Bruno(int n, int l, vi a) {
    int pos = 0;
    for(int i = 0; i < 17; i++)
        pos |= a[i] << i;

    int sz = 17;
    vi zs;
    V<bool> be(n);

    fib[0] = fib[1] = 2;
    for(int i = 2; i < 70; i++)
        fib[i] = fib[i - 1] + fib[i - 2];

    for(int i = 0; i < n; i += 70) {
        ll tt = 0;
        for(int j = 0; j < 48; j++)
            tt += a[sz++] * (1LL << j);
        for(int j = 69; j >= 0; j--) {
            if(tt >= fib[j]) {
                be[i + j] = true;
                tt -= fib[j];
            }
        }
        assert(tt == 0);
    }
    for(int i = 0; i < n; i++) if(be[i]) {
        zs.PB(i);
    }

    vi aux;
    for(int i = 0; i <= pos; i++)
        aux.PB(i);
    reverse(ALL(zs));

    for(int i = pos + 1; i < n; i++) {
        if(SZ(zs) && zs.back() == i) {
            zs.pop_back();
            while(aux.back() != pos) {
                Remove(aux.back());
                aux.pop_back();
            }
            Remove(i);
        } else {
            aux.PB(i);
        }
    }
    for(int i:aux)
        Remove(i);

}

Compilation message

Anna.cpp:22:6: warning: 'void {anonymous}::DBG()' defined but not used [-Wunused-function]
   22 | void DBG() { cerr << "]" << _reset << endl; }
      |      ^~~

Bruno.cpp:22:6: warning: 'void {anonymous}::DBG()' defined but not used [-Wunused-function]
   22 | void DBG() { cerr << "]" << _reset << endl; }
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 544 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 0 ms 504 KB Output is correct
4 Correct 1 ms 516 KB Output is correct
5 Correct 0 ms 508 KB Output is correct
6 Correct 1 ms 516 KB Output is correct
7 Correct 0 ms 516 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 0 ms 504 KB Output is correct
10 Correct 1 ms 508 KB Output is correct
11 Correct 0 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 852 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -