# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97558 | shoemakerjo | Broken Device (JOI17_broken_device) | C++14 | 68 ms | 3328 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Annalib.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool marked[200];
void Anna( int N, ll X, int K, int P[] ){
for (int i = 0; i < N; i++) marked[i] = false;
for (int i = 0; i < K; i++) {
marked[P[i]] = true;
}
int a, b, c;
for (int i = 0; i < N; i += 3) {
a = i; b = i+1; c = i+2;
int ct = 0;
if (marked[a]) ct++;
if (marked[b]) ct++;
if (marked[c]) ct++;
if (ct >= 2) {
Set(a, 0); Set(b, 0); Set(c, 1);
continue;
}
if (ct == 0) {
//set all to 1 for a 1 bit
if (X % 4 == 0) {
Set(a, 0); Set(b, 1); Set(c, 1);
}
if (X % 4 == 2) {
Set(a, 0); Set(b, 1); Set(c, 0);
}
if (X % 4 == 1) {
Set(a, 1); Set(b, 0); Set(c, 1);
}
if (X % 4 == 3) {
Set(a, 1); Set(b, 1); Set(c, 1);
}
X /= 4;
}
if (ct == 1) {
if (X % 2 == 0) {
if (marked[a]) {
if (X % 4 == 0) {
Set(a, 0); Set(b, 1); Set(c, 1);
}
else {
Set(a, 0); Set(b, 1); Set(c, 0);
}
X/=4;
}
else {
Set(a, 1); Set(b, 0); Set(c, 0);
X /= 2;
}
}
else {
if (marked[c]) {
Set(a, 1); Set(b, 1); Set(c, 0);
}
else {
Set(a, 0); Set(b, 0); Set(c, 1);
}
X /= 2;
}
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll Bruno( int N, int A[] ){
ll res = 0;
for (int i = N-1; i > 0; i -= 3) {
int a = i-2;
int b = i-1;
int c = i;
if (A[a] == 0 && A[b] == 0 && A[c] == 0) continue;
int cv = (A[c] == 0) + 2*(A[b] == 1) + 4*(A[a] == 0);
if (cv == 1) {
res = res * 2 + 1;
}
if (cv == 2) {
res = res * 4 + 2;
}
if (cv == 3) {
res = res * 4 + 0;
}
if (cv == 4) {
res = res * 2 + 0;
}
if (cv == 5) {
res = res * 4 + 1;
}
if (cv == 6) {
res = res * 2 + 1;
}
if (cv == 7) {
res = res * 4 + 3;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |