제출 #1167223

#제출 시각아이디문제언어결과실행 시간메모리
1167223fryingducBroken Device (JOI17_broken_device)C++20
100 / 100
19 ms1572 KiB
#include "Annalib.h" #include "bits/stdc++.h" using namespace std; namespace { string c0[] = {"001", "011", "110", "111"}; string c1[] = {"101", "010"}; // 100 const int maxn = 155; int n, k, p[maxn]; long long x; bool ban[maxn]; string s; } void Anna(int N, long long X, int K, int P[]) { memset(ban, 0, sizeof(ban)); n = N, x = X, k = K; s.clear(); for (int i = 0; i < k; ++i) { ban[P[i]] = 1; } int bit = 59; for (int i = 0; i < n; i += 3) { if (bit < 0) { for (int j = i; j < n; ++j) { s += '0'; } break; } int cnt = 0; for (int j = i; j <= i + 2; ++j) cnt += ban[j]; if (cnt > 1) { s += "000"; continue; } if (cnt == 0) { int cur = ((x >> bit & 1) << 1) | (bit == 0 ? 0 : x >> (bit - 1) & 1); bit -= 2; s += c0[cur]; } else { if (x >> bit & 1) { s += c1[!ban[i + 1]]; --bit; } else { if (!ban[i]) { s += "100"; --bit; } else { int b = (bit == 0 ? 0 : (x >> (bit - 1) & 1)); bit -= 2; s += c0[b]; } } } } assert((int)s.size() == 150); for (int i = 0; i < n; ++i) { Set(i, s[i] - '0'); } }
#include "Brunolib.h" #include "bits/stdc++.h" using namespace std; namespace { string cc0[] = {"001", "011", "110", "111"}; string cc1[] = {"101", "010"}; // 100 } long long Bruno (int N, int A[]) { string s; for (int i = 0; i < N; i += 3) { string x; x += char('0' + A[i]); x += char('0' + A[i + 1]); x += char('0' + A[i + 2]); if (x == "000") continue; int p = -1; for (int j = 0; j < 4; ++j) { if (x == cc0[j]) { p = j; break; } } if (p != -1) { s += char('0' + (p >> 1)); s += char('0' + (p & 1)); continue; } for (int j = 0; j < 2; ++j) { if (x == cc1[j]) { s += "1"; p = j; break; } } if (p == -1) { s += "0"; } } long long res = 0; for (int j = 0; j < 60; ++j) { if (s[j] == '1') res |= (1ll << (60 - j - 1)); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...