# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
556441 | blue | Broken Device (JOI17_broken_device) | C++17 | 41 ms | 2376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Annalib.h"
#include <vector>
#include <iostream>
#include <string>
using namespace std;
namespace
{
using vi = vector<int>;
using ll = long long;
#define sz(x) int(x.size())
vector<string> key = vector<string>{string{""}, string{"0"}, string{"1"}, string{"00"}, string{"10"}, string{"11"}, string{"0"}, string{"01"}};
}
void Anna(int N, ll X, int K, int P[])
{
string bs(200, '0');
for(int b = 0; b < 200; b++)
{
bs[b] = (X%2) + '0';
X >>= 1;
}
vi br(N, 0); //broken
for(int i = 0; i < K; i++)
br[P[i]] = 1;
int cb = 0;
// cerr << "N = " << N << '\n';
for(int i = 0; i < N; i += 3)
{
// cerr << "i = " << i << "\n";
int cbr = br[i] + 2*br[i+1] + 4*br[i+2];
for(int b2 : {3, 4, 5, 7, 1, 2, 6, 0})
{
bool valid = 1;
// cerr << "cbr = " << cbr << ", cb = " << cb << '\n';
// cerr << bs[cb] << ' ' << bs[cb+1] << '\n';
for(int f = 0; f < sz(key[b2]); f++)
if(key[b2][f] != bs[cb+f])
valid = 0;
if(!valid) continue;
// cerr << "going for " << b2 << '\n';
if((b2 & cbr) == 0)
{
cb += sz(key[b2]);
for(int j = 0; j < 3; j++)
{
// cerr << "set : " << i+j << '\n';
Set(i + j, (b2 >> j) & 1);
}
break;
}
}
}
// cerr << "terminated\n";
}
#include "Brunolib.h"
#include <vector>
#include <string>
using namespace std;
namespace
{
using vi = vector<int>;
using ll = long long;
#define sz(x) int(x.size())
vector<string> key = vector<string>{string{""}, string{"0"}, string{"1"}, string{"00"}, string{"10"}, string{"11"}, string{"0"}, string{"01"}};
}
ll Bruno(int N, int A[])
{
string res_s;
for(int i = 0; i < N; i += 3)
{
int z = A[i] + 2*A[i+1] + 4*A[i+2];
res_s += key[z];
}
ll bs = 1;
ll res = 0;
for(int i = 0; i < 60; i++)
{
if(res_s[i] == '1')
res += bs;
bs *= 2;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |