# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
991381 | onbert | Broken Device (JOI17_broken_device) | C++17 | 30 ms | 2648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int m = 37;
const int R[40] = {0, 0, 2, 2, 1, 1, 0, 0, 1, 2, 0, 2, 1, 1, 2, 2, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 2, 0, 1, 1, 0, 2, 2, 2, 2, 1, 0};
void Anna(int32_t n, long long X, int32_t k, int32_t p[]){
int a[n];
for (int i=0;i<n;i++) a[i] = 1;
for (int i=0;i<k;i++) a[p[i]] = 0;
int cur = 0;
for (int i=0;i<n;i+=2) {
int val = (X + R[cur]) % 3;
int x = 1, y = 1;
if (val==0) x = 0, y = 1;
if (val==1) x = 1, y = 0;
if (((!a[i]) && x) || ((!a[i+1]) && y)) {
a[i] = a[i+1] = 0;
continue;
}
a[i] = x, a[i+1] = y;
X /= 3;
cur++;
}
// for (int i=0;i<n;i++) cout << a[i]; cout << endl;
for (int i=0;i<n;i++) Set(i, (int32_t)a[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int m = 37;
const int R[40] = {0, 0, 2, 2, 1, 1, 0, 0, 1, 2, 0, 2, 1, 1, 2, 2, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 2, 0, 1, 1, 0, 2, 2, 2, 2, 1, 0};
long long Bruno(int32_t n, int32_t a[]){
int pwr[m+1];
pwr[0] = 1;
for (int i=1;i<=m;i++) pwr[i] = pwr[i-1] * 3;
int x = 0;
int cur = 0;
for (int i=0;i<n && cur<=m;i+=2) if (a[i]==1 || a[i+1]==1) {
int bit = 0;
if (a[i]==1 && a[i+1]==0) bit = 1;
if (a[i]==1 && a[i+1]==1) bit = 2;
bit = (bit - R[cur] + 3) % 3;
x += bit * pwr[cur];
cur++;
}
// cout << endl;
return x;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |