# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705427 | lukameladze | Broken Device (JOI17_broken_device) | C++14 | 0 ms | 0 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;
// 1 ---- > 0
// 2 ---- > 1
// 5 ---- > 1
// 3 ---- > 10
// 4 ---- > 00
// 6 ---- > 01
// 7 ---- > 11
void Anna( int N, long long X, int K, int P[] ){
std::vector <int> bit, fix;
bit = vector <int> (65, 0);
fix = vector <int> (155, 0);
for (int i = 0; i < 60; i++) {
bit[i] = ((1LL<<i)&X ? 1 : 0);
}
for (int i = 0; i < K; i++) {
fix[P[i]] = 1;
}
int cur = 0;
for (int i = 0; i < 150; i+=3) {
int bl = fix[i] + fix[i + 1] + fix[i + 2];
if (bl >= 2) {
assign(i, 0);
continue;
}
if (bl == 0) {
int val = bit[cur] * 2 + bit[cur];
cur += 2;
if (val == 3) {
assign(i, 7); continue;
}
if (val == 0) {
assign(i, 4); continue;
}
if (val == 1) {
assign(i, 6); continue;
}
if (val == 2) {
assign(i, 3); continue;
}
}
assert(bl == 1);
int val = bit[cur];
if (!fix[i + 2] && val == 0) {
cur++; assign(i, 1); continue;
}
if (!fix[i + 1] && val == 1) {
cur++; assign(i, 2); continue;
}
int val1 = bit[cur + 1];
if (val == 0) { // i da i + 1 emp
if (val1 == 0) {
assign(i, 4); cur += 2; continue;
}
if (val1 == 1) {
assign(i, 6); cur += 2; continue;
}
}
// i da i + 2 emp
if (val1 == 0) {
assign(i, 5); cur++; continue;
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
// 1 ---- > 0
// 2 ---- > 1
// 5 ---- > 1
// 3 ---- > 10
// 4 ---- > 00
// 6 ---- > 01
// 7 ---- > 11
long long Bruno( int N, int A[] ){
string get[10];
get[1] = "0";
get[2] = "1";
get[5] = "1";
get[3] = "10";
get[4] = "00";
get[6] = "01";
get[7] = "11";
string ans = "";
for (int i = 0; i < 150; i += 3) {
int x = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
ans += get[x];
}
long long res = 0;
for (int i = 0; i < ans.size(); i++) {
res += (ans[i] == '1' ? (1LL<<i) : 0);
}
return res;
}