# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26832 | wangyenjen | Broken Device (JOI17_broken_device) | C++14 | 0 ms | 4636 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// Author: Wang, Yen-Jen
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
static bool st[150];
static int cnt[30];
void Anna(int N , long long X , int K , int P[]) {
memset(st , 0 , sizeof(st));
memset(cnt , 0 , sizeof(cnt));
for(int i = 0; i < K; i++) {
st[P[i]] = 1;
cnt[P[i] / 3]++;
}
int cc = 0;
for(int i = 0; i < N / 3; i++) {
if(cc >= 60 || cnt[i] == 3) {
Set(i * 3 , 0);
Set(i * 3 + 1 , 0);
Set(i * 3 + 2 , 0);
continue;
}
if(cnt[i] == 2) {
if(!st[i * 3]) {
if((~(X>>cc)&1) && (~(X>>(cc + 1))&1)) {
Set(i * 3 , 1);
Set(i * 3 + 1 , 0);
Set(i * 3 + 2 , 0);
cc += 2;
}
}
else if(!st[i * 3 + 1]) {
if(~(X>>cc)&1) {
Set(i * 3 , 0);
Set(i * 3 + 1 , 1);
Set(i * 3 + 2 , 0);
cc++;
}
}
else {
if((X>>cc)&1) {
Set(i * 3 , 0);
Set(i * 3 + 1 , 0);
Set(i * 3 + 2 , 1);
cc++;
}
}
}
else if(cnt[i] == 0) {
Set(i * 3 , 1);
Set(i * 3 + 1 , (X>>cc)&1);
cc++;
Set(i * 3 + 2 , (X>>cc)&1);
cc++;
}
else {
if(st[i * 3]) {
Set(i * 3 , 0);
Set(i * 3 + 1 , 1);
Set(i * 3 + 2 , (X>>cc)&1);
cc++;
}
else if(st[i * 3 + 1]) {
if(~(X>>cc)&1) {
Set(i * 3 , 1);
Set(i * 3 + 1 , (X>>cc)&1);
cc++;
Set(i * 3 + 2 , (X>>cc)&1);
cc++;
}
else {
Set(i * 3 , 0);
Set(i * 3 + 1 , 0);
Set(i * 3 + 2 , 1);
cc++;
}
}
else {
if(~(X>>(cc + 1))&1) {
Set(i * 3 , 1);
Set(i * 3 + 1 , (X>>cc)&1);
cc++;
Set(i * 3 + 2 , (X>>cc)&1);
cc++;
}
else {
Set(i * 3 , 0);
Set(i * 3 + 1 , 0);
Set(i * 3 + 2 , 0);
}
}
}
}
}
/// Author: Wang, Yen-Jen
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno(int N , int A[]) {
long long X = 0;
int cc = 0;
for(int i = 0; i < N / 3; i++) {
if(A[i * 3]) {
X |= ((long long)A[i * 3 + 1]<<cc);
cc++;
X |= ((long long)A[i * 3 + 2]<<cc);
cc++;
}
else if(A[i * 3 + 1]) {
X |= ((long long)A[i * 3 + 2]<<cc);
cc++;
}
else if(A[i * 3 + 2]) {
X |= ((long long)A[i * 3 + 2]<<cc);
cc++;
}
}
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |