답안 #684509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684509 2023-01-21T11:36:12 Z mjhmjh1104 Ancient Machine (JOI21_ancient_machine) C++17
100 / 100
57 ms 8572 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 (curr[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 516 KB Output is correct
2 Correct 0 ms 516 KB Output is correct
3 Correct 0 ms 516 KB Output is correct
4 Correct 0 ms 508 KB Output is correct
5 Correct 0 ms 516 KB Output is correct
6 Correct 0 ms 508 KB Output is correct
7 Correct 0 ms 508 KB Output is correct
8 Correct 0 ms 512 KB Output is correct
9 Correct 0 ms 512 KB Output is correct
10 Correct 1 ms 516 KB Output is correct
11 Correct 2 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 7972 KB Output is correct
2 Correct 48 ms 8380 KB Output is correct
3 Correct 48 ms 8416 KB Output is correct
4 Correct 47 ms 8336 KB Output is correct
5 Correct 50 ms 8536 KB Output is correct
6 Correct 48 ms 8488 KB Output is correct
7 Correct 48 ms 8440 KB Output is correct
8 Correct 47 ms 8368 KB Output is correct
9 Correct 48 ms 8308 KB Output is correct
10 Correct 47 ms 8412 KB Output is correct
11 Correct 47 ms 8356 KB Output is correct
12 Correct 47 ms 8412 KB Output is correct
13 Correct 54 ms 8436 KB Output is correct
14 Correct 53 ms 8332 KB Output is correct
15 Correct 54 ms 8304 KB Output is correct
16 Correct 53 ms 8436 KB Output is correct
17 Correct 54 ms 8296 KB Output is correct
18 Correct 52 ms 8428 KB Output is correct
19 Correct 54 ms 8316 KB Output is correct
20 Correct 46 ms 8360 KB Output is correct
21 Correct 49 ms 8464 KB Output is correct
22 Correct 52 ms 8536 KB Output is correct
23 Correct 47 ms 8452 KB Output is correct
24 Correct 47 ms 8572 KB Output is correct
25 Correct 51 ms 8436 KB Output is correct
26 Correct 57 ms 8300 KB Output is correct
27 Correct 53 ms 8496 KB Output is correct
28 Correct 52 ms 8388 KB Output is correct
29 Correct 54 ms 8336 KB Output is correct
30 Correct 53 ms 8408 KB Output is correct
31 Correct 52 ms 8480 KB Output is correct
32 Correct 46 ms 8288 KB Output is correct
33 Correct 46 ms 8456 KB Output is correct