Submission #709632

#TimeUsernameProblemLanguageResultExecution timeMemory
709632lmqzzzAncient Machine (JOI21_ancient_machine)C++17
5 / 100
31 ms2964 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"; 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 "Bruno.h" #include <bits/stdc++.h> using namespace std; void Bruno(int N, int L, std::vector<int> A) { 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: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) {
      |                                             ~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...