| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1297211 | nguyenkhangninh99 | Broken Device (JOI17_broken_device) | C++20 | 0 ms | 0 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int n, long long x, int k, int p[]){
vector<int> bad(n), res(n);
for(int i = 0; i < k; i++) bad[p[i]] 1;
for(int i = 0; i < n; i += 3){
if(bad[i] + bad[i + 1] + bad[i + 2] >= 2) continue;
if(bad[i] + bad[i + 1] + bad[i + 2] == 1){
if(x % 2 == 0){
if(bad[i]) res[i + 2] = 1;
else if(bad[i + 1]) res[i + 2] = 1;
else res[i] = res[i + 1] = 1;
}else{
if(bad[i]){
if(x % 4 == 1) res[i + 1] = 1;
else res[i + 1] = res[i + 2] = 1;
x /= 2;
}
if(bad[i + 1]) res[i] = 1;
if(bad[i + 2]) res[i] = 1;
}
x /= 2;
}else{
res[i] = res[i + 1] = res[i + 2] = 1;
if(x % 4 == 1) res[i] = res[i + 2] = 0;
else if(x % 4 == 2) res[i + 1] = 0;
else if(x % 4 == 3) res[i] = 0;
x /= 4;
}
}
for(int i = 0; i < n; i++) Set(i, res[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
void update(int &res, int t){
if(t == 1) res *= 2;
if(t == 2) res = res * 4 + 1;
if(t == 3) res = res * 4 + 3;
if(t == 4) res = res * 2 + 1;
if(t == 5) res = res * 4 + 2;
if(t == 6) res *= 2;
if(t == 7) res *= 4
}
long long Bruno(int n, int a[]){
long long res = 0;
for(int i = n - 3; i >= 0; i -= 3) update(res, 4 * a[i] + 2 * a[i + 1] + a[i + 2]);
return res;
}
