Submission #709627

# Submission time Handle Problem Language Result Execution time Memory
709627 2023-03-14T03:46:25 Z lmqzzz Ancient Machine (JOI21_ancient_machine) C++17
0 / 100
273 ms 262144 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";
        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) {
                ans.emplace_back(trace[cur]);
                cur ^= 1 << trace[cur];
        }
        reverse(ans.begin(), ans.end());
        for (int x : ans) send(x);
}
#include "Bruno.h"

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

void Bruno(int N, int L, std::vector<int> A) {
        assert(L % 17 == 0);
        vector<int> v;
        for (int i = 0; i < L; i += 17) {
                int pos = 0;
                for (int j = i; j < i + 17; j++) {
                        if (A[j]) pos |= 1 << (j - i);
                }
                Remove(pos);
        }
}

Compilation message

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:20:36: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   20 |                         if (i >> j & 1 ^ 1) {
      |                             ~~~~~~~^~~
Anna.cpp:23:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   23 |                                         if (i >> k & 1 ^ 1) {
      |                                             ~~~~~~~^~~
Anna.cpp:29:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   29 |                                         if (i >> k & 1 ^ 1) {
      |                                             ~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2564 KB Output is correct
2 Runtime error 273 ms 262144 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 820 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -