# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71620 | Bruteforceman | Broken Device (JOI17_broken_device) | C++11 | 76 ms | 3744 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;
// 100 = 0
// 011 = 0
// 010 = 1
// 101 = 1
// 111
// 101
// 110
// 000
void Anna( int N, long long X, int K, int P[] ){
int broke[N];
for(int i = 0; i < N; i++) {
broke[i] = 0;
}
for(int i = 0; i < K; i++) {
broke[P[i]] = 1;
}
string s = "";
int bit = 0;
for(int i = 0; i < N; i += 3) {
if(bit > 62) break;
int cnt = broke[i] + broke[i+1] + broke[i+2];
if(cnt == 1) {
if(broke[i]) {
if((X >> bit) & 1) {
s += "010";
} else {
s += "001";
}
++bit;
} else if (broke[i+1]) {
int p = (X >> bit) & 1;
++bit;
int q = (X >> bit) & 1;
++bit;
if(p == 0) {
s += "001";
--bit;
}
if(p == 1 && q == 0) s += "100";
if(p == 1 && q == 1) s += "101";
} else {
if((X >> bit) & 1) {
s += "010";
} else {
s += "110";
}
++bit;
}
} else if (cnt == 0) {
int p = (X >> bit) & 1;
++bit;
int q = (X >> bit) & 1;
++bit;
if(p == 0 && q == 0) {
s += "011";
}
if(p == 0 && q == 1) {
s += "111";
}
if(p == 1 && q == 0) {
s += "100";
}
if(p == 1 && q == 1) {
s += "101";
}
} else {
s += "000";
}
}
while(s.size() < N) {
s += "0";
}
// cerr << "bits covered: " << bit << endl;
for(int i = 0; i < N; i++) {
// cerr << i << ' ' << s[i] << endl;
Set(i, s[i] - '0');
}
}
#include "Brunolib.h"
#include "bits/stdc++.h"
using namespace std;
long long Bruno( int N, int A[] ){
int bit = 0;
long long ans = 0;
for(int i = 0; i < N; i += 3) {
if(bit > 61) break;
string s = "";
s += char (A[i] + '0');
s += char (A[i+1] + '0');
s += char (A[i+2] + '0');
if(s == "010") {
ans |= 1LL << bit;
++bit;
}
if(s == "001" || s == "110") {
++bit;
}
if(s == "011") {
bit += 2;
}
if(s == "111") {
++bit;
ans |= 1LL << bit;
++bit;
}
if(s == "100") {
ans |= 1LL << bit;
++bit;
++bit;
}
if(s == "101") {
ans |= 1LL << bit;
++bit;
ans |= 1LL << bit;
++bit;
}
}
// cerr << "found " << ans << endl;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |