# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1247342 | _asunaa | Broken Device (JOI17_broken_device) | C++20 | 0 ms | 320 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
long long i, j, l, r, mid, p, q, k, t, n, m, a, b, c, d, ans, cnt, res, arr[1000005];
const long long mod = 999993143, mod2 = 999993469;
bool check;
void Anna (int N, long long X, int K, int P[]){
string s = " ";
while (N > 1){
s.push_back((char)(N % 2 + 48));
N /= 2;
}
s.push_back((char)(N + 48));
d = s.length() - 1;
p = 1;
for (i = 1; i <= N; i += 1){
arr[i] = 0;
}
for (i = 0; i < K; i += 1){
arr[P[i]] = 1;
}
for (i = 1; i <= N; i += 3){
res = arr[i] + arr[i + 1] + arr[i + 2];
if (res >= 2 || p > d){
Set(i - 1, 0);
Set(i, 0);
Set(i + 1, 0);
}
if (res == 1){
if (p == d){
s += "0";
}
if (s[p] == 49){
if (arr[i] == 1){
Set(i - 1, 0);
Set(i, 1);
Set(i + 1, 1);
}
else{
Set(i - 1, 1);
Set(i, 0);
Set(i + 1, 0);
}
p += 1;
}
else{
if (arr[i + 2] == 1){
if (s[p + 1] == 48){
Set(i - 1, 0);
Set(i, 1);
Set(i + 1, 0);
}
else{
Set(i - 1, 1);
Set(i, 1);
Set(i + 1, 0);
}
p += 2;
}
else{
Set(i - 1, 0);
Set(i, 0);
Set(i + 1, 1);
p += 1;
}
}
}
else{
if (p == d){
s += "0";
}
if (s[p] == 49 && s[p + 1] == 49){
Set(i - 1, 1);
Set(i, 1);
Set(i + 1, 1);
}
else if (s[p] == 49 && s[p + 1] == 48){
Set(i - 1, 1);
Set(i, 0);
Set(i + 1, 1);
}
else if (s[p] == 48 && s[p + 1] == 49){
Set(i - 1, 1);
Set(i, 1);
Set(i + 1, 0);
}
else{
Set(i - 1, 0);
Set(i, 1);
Set(i + 1, 0);
}
}
}
return;
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long i, j, l, r, mid, p, q, k, t, n, m, a, b, c, d, ans, cnt, res, arr[1000005];
const long long mod = 999993143, mod2 = 999993469;
bool check;
long long Bruno (int N, int A[]){
string s;
ans = 0;
s = " ";
for (i = 1; i <= N; i += 1){
if (A[i - 1] == 0 && A[i] == 0 && A[i + 1] == 0){
continue;
}
else if (A[i - 1] == 0 && A[i] == 0 && A[i + 1] == 1){
s += "0";
}
else if (A[i - 1] == 0 && A[i] == 1 && A[i + 1] == 0){
s += "00";
}
else if (A[i - 1] == 0 && A[i] == 1 && A[i + 1] == 1){
s += "1";
}
else if (A[i - 1] == 1 && A[i] == 0 && A[i + 1] == 0){
s += "1";
}
else if (A[i - 1] == 1 && A[i] == 0 && A[i + 1] == 1){
s += "10";
}
else if (A[i - 1] == 1 && A[i] == 1 && A[i + 1] == 0){
s += "01";
}
else{
s += "11";
}
}
for (i = 1; i < s.length(); i += 1){
ans += (long long)(s[i] - 48) * (1ll << (i - 1));
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |