Submission #709631

# Submission time Handle Problem Language Result Execution time Memory
709631 2023-03-14T03:52:30 Z lmqzzz Ancient Machine (JOI21_ancient_machine) C++17
Compilation error
0 ms 0 KB
#include "Anna.h"

#include <bits/stdc++.h>
using namespace std;

void send(int x) {
        bitset<17> a(x);
        for (int i = 0; i < 17; i++) Send(a[i]);
}

int f[1 << 18];
int trace[1 << 18];

void Anna(int N, std::vector<char> S) {
        string temp = "XYZ";
        memset(f, -1, sizeof f);
        f[0] = 0;
        trace[0] = -1;
        for (int i = 0; i < 1 << N; i++) {
                for (int j = 0; j < N; j++) {
                        if (i >> j & 1 ^ 1) {
                                bool okl = 0, okr = 0, okm = S[j] == 'Y';
                                for (int k = j - 1; k >= 0; k--) {
                                        if (i >> k & 1 ^ 1) {
                                                okl = S[k] == 'X';
                                                break;
                                        }
                                }
                                for (int k = j + 1; k < N; k++) {
                                        if (i >> k & 1 ^ 1) {
                                                okr = S[k] == 'Z';
                                                break;
                                        }
                                }
                                if (f[i | (1 << j)] < f[i] + (okl && okr && okm)) {
                                        f[i | (1 << j)] = f[i] + (okl && okr && okm);
                                        trace[i | (1 << j)] = j;
                                }
                        }
                }
        }
        int cur = (1 << N) - 1;
        vector<int> ans;
        while (trace[cur] != -1) {
                cerr << cur << ' ';
                ans.emplace_back(trace[cur]);
                cur ^= 1 << trace[cur];
        }
        reverse(ans.begin(), ans.end());
        for (int x : ans) send(x);
}
#include "Anna.h"

#include <bits/stdc++.h>
using namespace std;

void send(int x) {
        bitset<17> a(x);
        for (int i = 0; i < 17; i++) Send(a[i]);
}

int f[1 << 18];
int trace[1 << 18];

void Anna(int N, std::vector<char> S) {
        string temp = "XYZ";
        memset(f, -1, sizeof f);
        f[0] = 0;
        trace[0] = -1;
        for (int i = 0; i < 1 << N; i++) {
                for (int j = 0; j < N; j++) {
                        if (i >> j & 1 ^ 1) {
                                bool okl = 0, okr = 0, okm = S[j] == 'Y';
                                for (int k = j - 1; k >= 0; k--) {
                                        if (i >> k & 1 ^ 1) {
                                                okl = S[k] == 'X';
                                                break;
                                        }
                                }
                                for (int k = j + 1; k < N; k++) {
                                        if (i >> k & 1 ^ 1) {
                                                okr = S[k] == 'Z';
                                                break;
                                        }
                                }
                                if (f[i | (1 << j)] < f[i] + (okl && okr && okm)) {
                                        f[i | (1 << j)] = f[i] + (okl && okr && okm);
                                        trace[i | (1 << j)] = j;
                                }
                        }
                }
        }
        int cur = (1 << N) - 1;
        vector<int> ans;
        while (trace[cur] != -1) {
                cerr << cur << ' ';
                ans.emplace_back(trace[cur]);
                cur ^= 1 << trace[cur];
        }
        reverse(ans.begin(), ans.end());
        for (int x : ans) send(x);
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:21:36: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   21 |                         if (i >> j & 1 ^ 1) {
      |                             ~~~~~~~^~~
Anna.cpp:24:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   24 |                                         if (i >> k & 1 ^ 1) {
      |                                             ~~~~~~~^~~
Anna.cpp:30:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   30 |                                         if (i >> k & 1 ^ 1) {
      |                                             ~~~~~~~^~~

Bruno.cpp: In function 'void Anna(int, std::vector<char>)':
Bruno.cpp:21:36: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   21 |                         if (i >> j & 1 ^ 1) {
      |                             ~~~~~~~^~~
Bruno.cpp:24:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   24 |                                         if (i >> k & 1 ^ 1) {
      |                                             ~~~~~~~^~~
Bruno.cpp:30:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   30 |                                         if (i >> k & 1 ^ 1) {
      |                                             ~~~~~~~^~~
/usr/bin/ld: /tmp/cc9dyzzW.o: in function `send(int)':
Bruno.cpp:(.text+0x35): undefined reference to `Send(int)'
/usr/bin/ld: /tmp/cc9dyzzW.o: in function `Anna(int, std::vector<char, std::allocator<char> >)':
Bruno.cpp:(.text+0x372): undefined reference to `Send(int)'
/usr/bin/ld: /tmp/cch5kKtY.o: in function `main':
grader_bruno.cpp:(.text.startup+0x24d): undefined reference to `Bruno(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status