Submission #710410

# Submission time Handle Problem Language Result Execution time Memory
710410 2023-03-15T08:28:24 Z tanprodium 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 a) {
    cout << a << ' ';
}

void Anna(int N, vector<char> S) {
    for (int i = 0; i < N; i++)
    if (S[i] == 'X') {
        Send(0);
        Send(0);
    } else if (S[i] == 'Y') {
        Send(0);
        Send(1);
    } else {
        Send(1);
        Send(0);
    }
}

void solve() {
    int n;
    string s;
    vector<char> vs;
    cin >> n >> s;

    for (int i = 0; i < n; i++)
        vs.push_back(s[i]);

    Anna(n, vs);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}
#include "Bruno.h"
#include<bits/stdc++.h>

using namespace std;

template<class X, class Y>
    bool maximize(X &x, const Y &y) {
        if (y > x) {
            x = y;
            return (true);
        } else return (false);
    }

const int oo = 1e9;

void Remove(int d) {
    cout << d << ' ';
}

void Bruno(int N, int L, vector<int> A) {
    string s = "";

    for (int i = 0; i < L; i += 2) {
        if (A[i] == 0) {
            if (A[i + 1] == 0)
                s += 'X';
            else s += 'Y';
        } else s += 'Z';
    }

    int sz = N;
    int all = (1 << sz);
    vector<int> dp(all + 5, -oo), rem(all + 5, 0);
    dp[0] = 0;

    for (int mask = 0; mask < all; mask++) {
        vector<int> pos;

        for (int i = 0; i < sz; i++)
            if (!(mask >> i & 1))
                pos.push_back(i);

        int spos = (int)pos.size();

        for (int i = 0; i < spos; i++) {
            bool good = false;
            int cur = pos[i];

            if (i > 0 && i < spos - 1) {
                int pre = pos[i - 1];
                int suf = pos[i + 1];

                if (s[pre] == 'X' && s[cur] == 'Y' && s[suf] == 'Z')
                    good = true;
            }

            int nmask = mask | (1 << cur);

            if (maximize(dp[nmask], dp[mask] + good))
                rem[nmask] = cur;
        }
    }

    vector<int> ans;

    int mask = all - 1;
    while (mask) {
        int bit = rem[mask];
        ans.push_back(bit + 1);
        mask ^= (1 << bit);
    }

    reverse(ans.begin(), ans.end());

    for (int x : ans) Remove(x);
}

void solve() {
    int n;
    int l;
    vector<int> a;

    cin >> n >> l;

    for (int i = 1; i <= l; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    Bruno(n, l, a);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/cccKhkSv.o: in function `Send(int)':
grader_anna.cpp:(.text+0x30): multiple definition of `Send(int)'; /tmp/ccFWju6x.o:Anna.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/cccKhkSv.o: in function `main':
grader_anna.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccFWju6x.o:Anna.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccjB2dej.o: in function `Remove(int)':
grader_bruno.cpp:(.text+0x30): multiple definition of `Remove(int)'; /tmp/ccPBJayh.o:Bruno.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccjB2dej.o: in function `main':
grader_bruno.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPBJayh.o:Bruno.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status