# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1136391 | adaawf | Broken Device (JOI17_broken_device) | C++17 | 37 ms | 1484 KiB |
#include <bits/stdc++.h>
#include "Annalib.h"
using namespace std;
int dd[10005];
void Anna(int n, long long int x, int k, int p[]) {
for (int i = 0; i < n; i++) dd[i] = 0;
for (int i = 0; i < k; i++) {
dd[p[i]] = 1;
}
int j = 0;
string s = "";
while (x) {
if (x & 1) s += '1';
else s += '0';
x /= 2;
}
while (s.size() < 60) s += '0';
string res = "";
for (int i = 0; i < n; i += 3) {
if (dd[i] + dd[i + 1] + dd[i + 2] >= 2 || j >= s.size()) continue;
string h = "";
if (dd[i] + dd[i + 1] + dd[i + 2] == 0) {
h += s[j++];
if (j < s.size()) h += s[j++];
}
else {
h += s[j++];
}
if (h == "00") res += "001";
else if (h == "01") res += "011";
else if (h == "10") res += "110";
else if (h == "11") res += "111";
else if (h == "1") {
if (dd[i + 1]) res += "101";
else res += "010";
}
else {
if (j < s.size() && dd[i]) {
if (s[j] == '0') {
res += "001";
}
else {
res += "011";
}
j++;
continue;
}
res += "100";
}
}
while (res.size() < 150) res += '0';
for (int i = 0; i < n; i++) {
Set(i, res[i] - '0');
}
}
#include <bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
int dd[10005];
long long int Bruno(int n, int a[]) {
string s = "";
for (int i = 0; i < n; i += 3) {
string h = "";
h += char(a[i] + '0');
h += char(a[i + 1] + '0');
h += char(a[i + 2] + '0');
if (h == "000") continue;
if (h == "001") s += "00";
if (h == "011") s += "01";
if (h == "110") s += "10";
if (h == "111") s += "11";
if (h == "101") s += "1";
if (h == "010") s += "1";
if (h == "100") s += "0";
}
long long int c = 0;
for (int i = 0; i < 60; i++) {
if (s[i] == '1') c += (1ll << i);
}
return c;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |