# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1165388 | who | Broken Device (JOI17_broken_device) | C++20 | 28 ms | 1568 KiB |
#include <bits/stdc++.h>
#include "Annalib.h"
using namespace std;
void Anna(int N, long long X, int K, int P[])
{
string key[8] =
{
"",
"0",
"10",
"11",
"1",
"01",
"0",
"00"
};
bool mark[N] = {false};
for (int i=0; i<K; i++) mark[P[i]] = true;
auto get = [&](int pos) -> int
{
return (X >> pos) & 1;
};
int bit = 0;
for (int i=0; i<N; i+=3)
{
int res = 0;
if ((X >> bit) == 0)
{
for (int j=0; j<3; j++) Set(i+j, 0);
continue;
}
for (int x=1; x<8; x++)
{
bool ok = true;
for (int j=0; j<3; j++)
{
if (mark[i+j] && ((x >> j) & 1))
{
ok = false;
break;
}
}
if (ok == false) continue;
if (key[x].size() == 2)
{
if (key[x][0] - '0' == get(bit) && key[x][1] - '0' == get(bit+1))
{
res = x;
break;
}
} else if (key[x][0] - '0' == get(bit)) res = x;
}
for (int j=0; j<3; j++) Set(i+j, (res >> j) & 1);
bit += key[res].size();
}
}
#include <bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
long long Bruno( int N, int A[] )
{
string key[8] =
{
"",
"0",
"10",
"11",
"1",
"01",
"0",
"00"
};
long long res = 0;
string s = "";
for (int i=0; i<N; i+=3)
{
int x=0;
for (int j=0; j<3; j++)
{
x += A[i+j] << j;
}
s += key[x];
}
for (int i=0; i<s.size(); i++)
{
res += ((long long) (s[i] - '0')) << i;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |