Submission #709627

#TimeUsernameProblemLanguageResultExecution timeMemory
709627lmqzzzAncient Machine (JOI21_ancient_machine)C++17
0 / 100
273 ms262144 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...