# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1219712 | pera | Broken Device (JOI17_broken_device) | C++20 | 19 ms | 1552 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
void Anna( int N, long long X, int K, int P[] ){
vector<bool> mark(N);
for(int i = 0;i < K;i ++){
mark[P[i]] = true;
}
for(int i = 0;i < N;i += 2){
int bit = X % 2;
int nbit = (X / 2) % 2;
if(mark[i] && mark[i + 1]){
Set(i , 0);
Set(i + 1 , 0);
}else if(mark[i]){
if(bit && !nbit){
Set(i , 0);
Set(i + 1 , 1);
X /= 2;
X /= 2;
}else{
Set(i , 0);
Set(i + 1 , 0);
}
}else if(mark[i + 1]){
if(bit && nbit){
Set(i , 1);
Set(i + 1 , 0);
X /= 2;
X /= 2;
}else{
Set(i , 0);
Set(i + 1 , 0);
}
}else{
if(bit && !nbit){
Set(i , 0);
Set(i + 1 , 1);
X /= 2;
X /= 2;
}else if(bit && nbit){
Set(i , 1);
Set(i + 1 , 0);
X /= 2;
X /= 2;
}else{
Set(i , 1);
Set(i + 1 , 1);
X /= 2;
}
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno( int N, int A[] ){
long long ans = 0;
int bit = 0;
for(int i = 0;i < N;i += 2){
if(!(A[i] ^ A[i + 1])){
if(A[i] || A[i + 1]){
++bit;
}
continue;
}
if(!A[i] && A[i + 1]){
ans += (1LL << bit);
}else{
ans += (1LL << bit);
ans += (1LL << (bit + 1));
}
bit += 2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |