# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705914 | keta_tsimakuridze | Broken Device (JOI17_broken_device) | C++14 | 55 ms | 2652 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;
/*
001->0
010->00
100->1
011->1
110->10
111->11
101->01
*/
void add(int id, int v1, int v2, int v3) {
Set(id, v1); Set(id + 1, v2); Set(id + 2, v3);
}
void Anna( int n, long long x, int k, int p[] ){
vector<int> f(n);
for(int i = 0; i < k; i++) f[p[i]] = 1;
// 0111
for(int i = 0; i < n; i += 3) {
if(f[i] + f[i + 1] + f[i + 2] == 0) {
if(x % 4 == 0) add(i, 0, 1, 0);
if(x % 4 == 1) add(i, 1, 0, 1);
if(x % 4 == 2) add(i, 1, 1, 0);
if(x % 4 == 3) add(i, 1, 1, 1);
x /= 4;
continue;
}
if(f[i] + f[i + 1] + f[i + 2] == 1) {
if(x % 2 == 0) {
if(!f[i + 2]) add(i, 0, 0, 1), x /= 2;
else if(x % 4 == 0) add(i, 0, 1, 0), x /= 4;
else add(i, 1, 1, 0), x /= 4;
continue;
}
if(!f[i]) add(i, 1, 0, 0);
else add(i, 0, 1, 1);
x /= 2;
} else add(i, 0, 0, 0);
}
}
/*
2
150 9 2
0 1 */
#include "Brunolib.h"
/*
001->0
010->00
100->1
011->1
110->10
111->11
101->01
*/
long long Bruno( int n, int A[] ){
long long ans = 0, c = 0;
for(int i = 0; i < n; i += 3) {
int x = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
if(!x) continue;
if(x == 1) ++c;
else if(x == 2) c += 2;
else if(x == 3 || x == 4) ans += 1ll << c, ++c;
else if(x == 5) ans += 1ll << c, c += 2;
else if(x == 6) ans += 1ll << (c + 1), c += 2;
else ans += (1ll << c) + (1ll << (c + 1)), c += 2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |