답안 #684508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684508 2023-01-21T11:32:55 Z mjhmjh1104 Ancient Machine (JOI21_ancient_machine) C++17
5 / 100
51 ms 8412 KB
#include "Anna.h"
#include <vector>
using namespace std;

unsigned long long dp[99][2];

void Anna(int n, vector<char> s) {
    int k = 0;
    bool skip = false;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        if (skip) skip = false;
        else if (s[i] == 'X') v.push_back(1), v.push_back(0), skip = true;
        else v.push_back(0);
        if (s[i] == 'Z') k = i;
    }
    while ((int)v.size() > n) v.pop_back();
    dp[62][0] = dp[62][1] = 1;
    for (int i = 61; i >= 0; i--) {
        dp[i][0] = dp[i + 1][0] + dp[i + 1][1];
        dp[i][1] = dp[i + 1][0];
    }
    vector<int> curr;
    for (int i = 0; i < n; i += 63) {
        curr.clear();
        for (int j = i; j < i + 63 && j < n; j++) curr.push_back(v[j]);
        while ((int)curr.size() < 63) curr.push_back(0);
        long long m = 0;
        for (int i = 0; i < 63; i++) if (v[i]) m += dp[i][0];
        for (int i = 0; i < 44; i++) Send(m & 1LL << i ? 1 : 0);
    }
    for (int t = 0; t <= 16; t++) Send(k & 1 << t ? 1 : 0);
}
#include "Bruno.h"
#include <vector>
using namespace std;

unsigned long long dp[99][2];

void Bruno(int n, int l, vector<int> b) {
    dp[62][0] = dp[62][1] = 1;
    for (int i = 61; i >= 0; i--) {
        dp[i][0] = dp[i + 1][0] + dp[i + 1][1];
        dp[i][1] = dp[i + 1][0];
    }
    int lt = n, rt = 0;
    vector<int> a;
    for (int i = 0; i < (int)b.size() - 17; i += 44) {
        long long m = 0;
        for (int j = 0; j < 44; j++) if (b[i + j]) m |= 1LL << j;
        for (int i = 0; i < 63; i++) {
            if (m >= dp[i][0]) {
                m -= dp[i][0];
                a.push_back(1);
            } else a.push_back(0);
        }
    }
    while ((int)a.size() > n) a.pop_back();
    for (int i = (int)b.size() - 17; i < (int)b.size(); i++) a.push_back(b[i]);
    for (int t = 0; t <= 16; t++) if (a[n + t]) rt |= 1 << t;
    for (int i = n - 1; i >= 0; i--) if (a[i] || !i) {
        for (int j = i + 1; j < lt; j++) if (a[j]) Remove(j);
        for (int j = i + 1; j < lt; j++) if (!a[j] && j != rt) Remove(j);
        if (i != rt) Remove(i);
        lt = i;
    }
    Remove(rt);
}

Compilation message

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:19:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   19 |             if (m >= dp[i][0]) {
      |                 ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 568 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 520 KB Output is correct
5 Correct 0 ms 512 KB Output is correct
6 Correct 1 ms 516 KB Output is correct
7 Correct 0 ms 520 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 0 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 8412 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -