# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530639 | byunjaewoo | Broken Device (JOI17_broken_device) | C++17 | 52 ms | 2704 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.
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
bool chk[155];
void MySet(int p, int a, int b, int c) {
Set(p, a); Set(p+1, b); Set(p+2, c);
}
void Anna( int N, long long X, int K, int P[] ){
fill(chk, chk+151, 0);
for(int i=0; i<K; i++) chk[P[i]]=1;
vector<bool> V;
while(X) {
V.push_back(X%2);
X/=2;
}
for(int i=0, p=0; i<150; i+=3) {
if(p>=V.size()) {
MySet(i, 0, 0, 0);
continue;
}
if(chk[i]+chk[i+1]+chk[i+2]==0) {
if(p==V.size()-1) V.push_back(0);
if(V[p]==0 && V[p+1]==0) MySet(i, 1, 0, 0);
else if(V[p]==0 && V[p+1]==1) MySet(i, 1, 0, 1);
else if(V[p]==1 && V[p+1]==0) MySet(i, 0, 1, 1);
else MySet(i, 1, 1, 1);
}
else if(chk[i]+chk[i+1]+chk[i+2]==1) {
if(chk[i]) {
if(V[p]==0) MySet(i, 0, 1, 0);
else MySet(i, 0, 0, 1);
p++;
}
else if(chk[i+1]) {
if(V[p]==0) {
if(p==V.size()-1) V.push_back(0);
if(V[p+1]==0) MySet(i, 1, 0, 0);
else MySet(i, 1, 0, 1);
p+=2;
}
else {MySet(i, 0, 0, 1); p++;}
}
else {
if(V[p]==0) MySet(i, 0, 1, 0);
else MySet(i, 1, 1, 0);
}
}
else MySet(i, 0, 0, 0);
}
}
#include <bits/stdc++.h>
using namespace std;
#include "Brunolib.h"
long long Bruno( int N, int A[] ){
long long x=0;
for(int i=N-1; i>=0; i-=3) {
int tmp=A[i-2]*4+A[i-1]*2+A[i];
if(tmp==1) x=x*2+1;
if(tmp==2) x*=2;
if(tmp==3) x=x*4+1;
if(tmp==4) x*=4;
if(tmp==5) x=x*4+2;
if(tmp==6) x=x*2+1;
if(tmp==7) x=x*4+3;
}
return x;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |