# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1077331 | AMO5 | Broken Device (JOI17_broken_device) | C++17 | 2 ms | 860 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;
void Anna( int N, long long X, int K, int P[] ){
std::vector<int>bad(N, 0);
for(int i=0; i<K; i++)bad[P[i]]=1;
auto setBlock=[&](int index, int a, int b, int c)->void{
Set(index, a);
Set(index+1, b);
Set(index+2, c);
};
long long tmp = X;
for(int i=0; i<N; i+=3){
int cnt = bad[i] + bad[i+1] + bad[i+2];
if(tmp == 0 || cnt >= 2){
setBlock(i, 0, 0, 0);
}else if(cnt == 0){
int bit = tmp % 4;
tmp /= 4;
if(bit == 2){
setBlock(i, 0, 1, 1);
}else{
setBlock(i, 1, tmp/2, tmp%2);
}
}else{
int bit = tmp % 2;
tmp /= 2;
if(bad[i]){
if(bit == 0) setBlock(i, 0, 1, 0);
else setBlock(i, 0, 0, 1);
}else if(bad[i+1]){
if(bit == 0){
int bit2 = tmp % 2;
tmp /= 2;
if(bit2 == 0) setBlock(i, 1, 0, 0);
else setBlock(i, 1, 0, 1);
}
else setBlock(i, 0, 0, 1);
}else{
if(bit == 0) setBlock(i, 0, 1, 0);
else setBlock(i, 1, 1, 0);
}
}
}
}
#include "Brunolib.h"
#include "bits/stdc++.h"
using namespace std;
long long Bruno( int N, int A[] ){
std::vector<int>bits;
for(int i=0; i<N; i+=3){
int val = 4 * A[i] + 2 * A[i+1] + A[i+2];
if(val == 0)continue;
if(val == 1) bits.emplace_back(1);
else if(val == 2) bits.emplace_back(0);
else if(val == 3) bits.emplace_back(1), bits.emplace_back(0);
else if(val == 4) bits.emplace_back(0), bits.emplace_back(0);
else if(val == 5) bits.emplace_back(0), bits.emplace_back(1);
else if(val == 6) bits.emplace_back(0);
else bits.emplace_back(1), bits.emplace_back(1);
}
long long answer = 0LL;
while(!bits.empty()){
answer *= 2LL;
answer += bits.back();
bits.pop_back();
}
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |