Submission #785773

#TimeUsernameProblemLanguageResultExecution timeMemory
785773MilosMilutinovicBroken Device (JOI17_broken_device)C++14
100 / 100
31 ms2684 KiB
#include "Annalib.h" #include <bits/stdc++.h> using namespace std; string str[] = {"0", "0", "1", "00", "10", "11", "0", "01"}; bool bad[200]; int cnt; void Anna(int N, long long X, int K, int P[]) { cnt = 0; for (int i = 0; i < N; i++) bad[i] = false; for (int i = 0; i < K; i++) bad[P[i]] = true; long long ptr = 0; for (int i = 0; i < N; i += 3) { int cnt = bad[i] + bad[i + 1] + bad[i + 2]; if (cnt >= 2 || ptr >= 64) { Set(i, 0); Set(i + 1, 0); Set(i + 2, 0); continue; } if (cnt == 0) { bool found = false; for (int j = 1; j <= 7; j++) { if (str[j].size() == 1) { continue; } int bit0 = (X >> ptr & 1); int bit1 = (X >> (ptr + 1) & 1); if ((str[j][0] - '0') == bit0 && (str[j][1] - '0') == bit1) { Set(i, j >> 2 & 1); Set(i + 1, j >> 1 & 1); Set(i + 2, j >> 0 & 1); found = true; break; } } assert(found); ptr += 2; continue; } int f = (bad[i] ? 2 : (bad[i + 1] ? 1 : 0)); bool found = false; for (int j = 1; j <= 7; j++) { if (j >> f & 1) { continue; } bool ok = true; for (int k = 0; k < (int) str[j].size(); k++) { int bit = (X >> (ptr + k) & 1); if (bit != (str[j][k] - '0')) { ok = false; } } if (ok) { found = true; Set(i, j >> 2 & 1); Set(i + 1, j >> 1 & 1); Set(i + 2, j >> 0 & 1); ptr += str[j].size(); break; } } } }
#include "Brunolib.h" #include <bits/stdc++.h> using namespace std; string str[] = {"0", "0", "1", "00", "10", "11", "0", "01"}; long long Bruno(int N, int A[]) { long long bit = 0; long long ans = 0; for (int i = 0; i < N; i += 3) { int x = A[i] * 4 + A[i + 1] * 2 + A[i + 2]; if (x == 0) { continue; } for (int j = 0; j < (int) str[x].size(); j++) { int d = (str[x][j] - '0'); ans += (1LL << bit) * d; bit += 1; } if (bit >= 60) { break; } } return ans; }

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:43:14: warning: variable 'found' set but not used [-Wunused-but-set-variable]
   43 |         bool found = false;
      |              ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...