# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1139929 | nathan4690 | Broken Device (JOI17_broken_device) | C++20 | 20 ms | 1584 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
void Anna( int N, long long X, int K, int P[] ){
vector<int> cnt(N / 3, 0);
vector<bool> flag(N, false);
for(int i=0;i<K;i++) {
cnt[P[i] % (N / 3)]++;
flag[P[i]] = true;
}
int idx = 0;
for(int i=0;i<N/3;i++){
int p1 = i, p2 = N / 3 + i, p3 = N / 3 * 2 + i;
if(cnt[i] == 0 && idx < 59){
long long val = (X >> (idx + 1) & 1) * 2 + (X >> idx & 1);
if(val == 0){
Set(p1, 1); Set(p2, 0); Set(p3, 1);
}else if(val == 1){
Set(p1, 0); Set(p2, 1); Set(p3, 1);
}else if(val == 2){
Set(p1, 1); Set(p2, 0); Set(p3, 0);
}else{
Set(p1, 1); Set(p2, 1); Set(p3, 1);
}
idx+=2;
}else if(cnt[i] <= 1 && idx < 60){
if(X >> idx & 1){
if(flag[p3]){
Set(p1, 1); Set(p2, 1); Set(p3, 0);
}else{
Set(p1, 0); Set(p2, 0); Set(p3, 1);
}
}else{
if(flag[p2]){
if(X >> (idx + 1) & 1){
Set(p1, 1); Set(p2, 0); Set(p3, 0);
}else{
Set(p1, 1); Set(p2, 0); Set(p3, 1);
}
idx += 2;
continue;
}
Set(p1, 0); Set(p2, 1); Set(p3, 0);
}
idx++;
}else{
Set(i, 0); Set(N / 3 + i, 0); Set(N / 3 * 2 + i, 0);
}
}
}
#include "Brunolib.h"
long long Bruno( int N, int A[] ){
long long res = 0, base = 1;
for(int i=0;i<N/3;i++){
int val = 0;
for(int j=i;j<N;j+=N/3){
val = val * 2 + A[j];
}
if(val == 0b111){
res += 3 * base;
base <<= 2;
}
if(val == 0b100){
res += 2 * base;
base <<= 2;
}
if(val == 0b101) base <<= 2;
if(val == 0b010) base <<= 1;
if(val == 0b110 || val == 0b001) {res += base; base <<= 1;}
if(val == 0b011) {res += base; base <<= 2;}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |