# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1152209 | siewjh | Broken Device (JOI17_broken_device) | C++20 | 22 ms | 1560 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void s3(int p, int v1, int v2, int v3){
Set(p, v1); Set(p + 50, v2); Set(p + 100, v3);
}
void Anna(int N, ll X, int K, int P[]){
vector<bool> br(N, 0);
for (int i = 0; i < K; i++) br[P[i]] = 1;
int id = 0;
for (int i = 0; i <= 59; id++){
int bt = (int)(br[id]) + br[id + 50] + br[id + 100];
if (bt >= 2){
s3(id, 0, 0, 0); continue;
}
ll v = X & (1ll << i), v2 = X & (1ll << (i + 1));
if (!v){
if (!v2){
if (br[id + 50]){
s3(id, 0, 0, 1); i++;
}
else if (br[id + 100]){
s3(id, 1, 1, 0); i++;
}
else{
s3(id, 0, 1, 1); i += 2;
}
}
else{
if (bt == 0){
s3(id, 1, 1, 1); i += 2;
}
else if (br[id + 100]){
s3(id, 1, 1, 0); i++;
}
else{
s3(id, 0, 0, 1); i++;
}
}
}
else{
if (!v2){
if (!br[id]){
s3(id, 1, 0, 0); i += 2;
}
else{
s3(id, 0, 1, 0); i++;
}
}
else{
if (br[id] || br[id + 100]){
s3(id, 0, 1, 0); i++;
}
else{
s3(id, 1, 0, 1); i += 2;
}
}
}
}
while (id < 50){
s3(id, 0, 0, 0); id++;
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll Bruno( int N, int A[] ){
ll ans = 0;
for (int i = 0, id = 0; id < 50; id++){
int val = (A[id] << 2) + (A[id + 50] << 1) + A[id + 100];
if (val == 0) continue;
else if (val == 1 || val == 6) i++;
else if (val == 2){
ans += (1ll << i); i++;
}
else if (val == 3) i += 2;
else if (val == 4){
ans += (1ll << i); i += 2;
}
else if (val == 5){
ans += (1ll << i) + (1ll << (i + 1)); i += 2;
}
else{
ans += (1ll << (i + 1)); i += 2;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |