# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
330869 | NachoLibre | Broken Device (JOI17_broken_device) | C++14 | 48 ms | 2944 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ANNACPP ANNACPP
// #define BRUNOCPP BRUNOCPP
#ifdef WEEE
#define ANNACPP ANNACPP
#define BRUNOCPP BRUNOCPP
int *mc = new int[150]();
void Set(int pos, int val) {
mc[pos] = val;
}
#endif
#ifdef ANNACPP
#ifndef WEEE
#include "Annalib.h"
#endif
void Anna(int n, long long x, int k, int* p) {
vector<int> v, g;
g.resize(n, 0);
for(int i = 0; i < k; ++i) {
g[p[i]] = 1;
}
int bt = 0;
for(int i = 0; i < n; i += 3) {
int jg = g[i] + g[i + 1] + g[i + 2];
if(jg >= 2 || bt > 60) {
v.push_back(0);
v.push_back(0);
v.push_back(0);
} else if(jg == 0) {
int tx = (((x & (1ll << bt)) << 1) | ((x & (1ll << (bt + 1))) >> 1)) >> bt;
bt += 2;
if(tx == 0) {
v.push_back(0);
v.push_back(1);
v.push_back(1);
} else if(tx == 1) {
v.push_back(1);
v.push_back(0);
v.push_back(1);
} else if(tx == 2) {
v.push_back(1);
v.push_back(1);
v.push_back(0);
} else if(tx == 3) {
v.push_back(1);
v.push_back(1);
v.push_back(1);
} else {
exit(1);
}
} else if(jg == 1) {
int tx = (x & (1ll << bt)) >> bt;
++bt;
if(tx == 0) {
if(g[i + 1]) {
tx = (x & (1ll << bt)) >> bt;
++bt;
if(tx == 0) {
v.push_back(0);
v.push_back(1);
v.push_back(1);
} else if(tx == 1) {
v.push_back(1);
v.push_back(0);
v.push_back(1);
} else {
exit(1);
}
} else {
v.push_back(0);
v.push_back(1);
v.push_back(0);
}
} else if(tx == 1) {
if(g[i]) {
v.push_back(0);
v.push_back(0);
v.push_back(1);
} else {
v.push_back(1);
v.push_back(0);
v.push_back(0);
}
} else {
exit(1);
}
}
}
for(int i = 0; i < n; ++i) {
Set(i, v[i]);
}
}
#endif
#ifdef BRUNOCPP
#ifndef WEEE
#include "Brunolib.h"
#endif
long long Bruno(int n, int* a) {
long long x = 0;
int bt = 0;
for(int i = 0; i < n; i += 3) {
int m = a[i] * 4 + a[i + 1] * 2 + a[i + 2];
if(m == 0);
else if(m == 1) x |= (1ll << bt), ++bt;
else if(m == 2) ++bt;
else if(m == 3) bt += 2;
else if(m == 4) x |= (1ll << bt), ++bt;
else if(m == 5) ++bt, x |= (1ll << bt), ++bt;
else if(m == 6) x |= (1ll << bt), bt += 2;
else if(m == 7) x |= (1ll << bt), ++bt, x |= (1ll << bt), ++bt;
}
return x;
}
#endif
#ifdef WEEE
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long x = 123456;
int *a = new int[5]();
a[0] = 0;
a[1] = 3;
a[2] = 7;
a[3] = 13;
a[4] = 19;
Anna(150, x, 5, a);
cout << Bruno(150, mc) << endl;
return 0;
}
#endif
#include <bits/stdc++.h>
using namespace std;
// #define ANNACPP ANNACPP
#define BRUNOCPP BRUNOCPP
#ifdef WEEE
#define ANNACPP ANNACPP
#define BRUNOCPP BRUNOCPP
int *mc = new int[150]();
void Set(int pos, int val) {
mc[pos] = val;
}
#endif
#ifdef ANNACPP
#ifndef WEEE
#include "Annalib.h"
#endif
void Anna(int n, long long x, int k, int* p) {
vector<int> v, g;
g.resize(n, 0);
for(int i = 0; i < k; ++i) {
g[p[i]] = 1;
}
int bt = 0;
for(int i = 0; i < n; i += 3) {
int jg = g[i] + g[i + 1] + g[i + 2];
if(jg >= 2 || bt > 60) {
v.push_back(0);
v.push_back(0);
v.push_back(0);
} else if(jg == 0) {
int tx = (((x & (1ll << bt)) << 1) | ((x & (1ll << (bt + 1))) >> 1)) >> bt;
bt += 2;
if(tx == 0) {
v.push_back(0);
v.push_back(1);
v.push_back(1);
} else if(tx == 1) {
v.push_back(1);
v.push_back(0);
v.push_back(1);
} else if(tx == 2) {
v.push_back(1);
v.push_back(1);
v.push_back(0);
} else if(tx == 3) {
v.push_back(1);
v.push_back(1);
v.push_back(1);
} else {
exit(1);
}
} else if(jg == 1) {
int tx = (x & (1ll << bt)) >> bt;
++bt;
if(tx == 0) {
if(g[i + 1]) {
tx = (x & (1ll << bt)) >> bt;
++bt;
if(tx == 0) {
v.push_back(0);
v.push_back(1);
v.push_back(1);
} else if(tx == 1) {
v.push_back(1);
v.push_back(0);
v.push_back(1);
} else {
exit(1);
}
} else {
v.push_back(0);
v.push_back(1);
v.push_back(0);
}
} else if(tx == 1) {
if(g[i]) {
v.push_back(0);
v.push_back(0);
v.push_back(1);
} else {
v.push_back(1);
v.push_back(0);
v.push_back(0);
}
} else {
exit(1);
}
}
}
for(int i = 0; i < n; ++i) {
Set(i, v[i]);
}
}
#endif
#ifdef BRUNOCPP
#ifndef WEEE
#include "Brunolib.h"
#endif
long long Bruno(int n, int* a) {
long long x = 0;
int bt = 0;
for(int i = 0; i < n; i += 3) {
int m = a[i] * 4 + a[i + 1] * 2 + a[i + 2];
if(m == 0);
else if(m == 1) x |= (1ll << bt), ++bt;
else if(m == 2) ++bt;
else if(m == 3) bt += 2;
else if(m == 4) x |= (1ll << bt), ++bt;
else if(m == 5) ++bt, x |= (1ll << bt), ++bt;
else if(m == 6) x |= (1ll << bt), bt += 2;
else if(m == 7) x |= (1ll << bt), ++bt, x |= (1ll << bt), ++bt;
}
return x;
}
#endif
#ifdef WEEE
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long x = 123456;
int *a = new int[5]();
a[0] = 0;
a[1] = 3;
a[2] = 7;
a[3] = 13;
a[4] = 19;
Anna(150, x, 5, a);
cout << Bruno(150, mc) << endl;
return 0;
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |