# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
627711 | MilosMilutinovic | Broken Device (JOI17_broken_device) | C++14 | 40 ms | 2452 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Annalib.h"
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
vector<int> ord = {126,24,39,3,96,102,108,138,132,60,114,111,30,12,87,147,90,54,129,72,81,42,15,45,141,18,33,57,144,120,9,27,84,75,69,0,123,48,117,21,93,78,135,36,66,6,63,105,99,51};
bool broken[150];
void Anna(int N, long long X, int K, int P[])
{
rep(i, 150) broken[i] = false;
rep(i, K) broken[P[i]] = true;
LL pw = 1;
while(pw + pw <= X) pw *= 3;
vector<int> bits;
while(X > 0) {
int cc = 0;
while(X >= pw) cc ++, X -= pw;
bits.push_back(cc);
pw /= 3;
}
while(pw > 0) {
bits.push_back(0);
pw /= 3;
}
reverse(bits.begin(), bits.end());
while(bits.back() == 0) bits.pop_back();
int ptr = 0;
for(int i : ord) {
int sum = 0;
if(!broken[i + 0]) sum ++;
if(!broken[i + 1]) sum ++;
if(!broken[i + 2]) sum ++;
if(ptr >= (int) bits.size() || sum == 0) {
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 0) {
if(!broken[i + 0]) {
Set(i + 0, 1);
Set(i + 1, 0);
Set(i + 2, 0);
ptr ++;
continue;
}
if(!broken[i + 1] && !broken[i + 2]) {
Set(i + 0, 0);
Set(i + 1, 1);
Set(i + 2, 1);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 1) {
if(!broken[i + 1]) {
Set(i + 0, 0);
Set(i + 1, 1);
Set(i + 2, 0);
ptr ++;
continue;
}
if(!broken[i + 0] && !broken[i + 2]) {
Set(i + 0, 1);
Set(i + 1, 0);
Set(i + 2, 1);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 2) {
if(!broken[i + 2]) {
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 1);
ptr ++;
continue;
}
if(!broken[i + 0] && !broken[i + 1]) {
Set(i + 0, 1);
Set(i + 1, 1);
Set(i + 2, 0);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
ptr ++;
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> ord = {126,24,39,3,96,102,108,138,132,60,114,111,30,12,87,147,90,54,129,72,81,42,15,45,141,18,33,57,144,120,9,27,84,75,69,0,123,48,117,21,93,78,135,36,66,6,63,105,99,51};
long long Bruno(int N, int A[])
{
long long X = 0, pw = 1;
for(int i : ord) {
int sum = A[i] + A[i + 1] + A[i + 2];
for(int j = 0; j < 3; j++) {
if(sum == 1 && A[i + j] == 1) {
X += pw * j;
pw *= 3;
}
if(sum == 2 && A[i + j] == 0) {
X += pw * j;
pw *= 3;
}
}
}
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |