# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126567 | briansu | Broken Device (JOI17_broken_device) | C++14 | 44 ms | 3320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i ++)
static ll fg;
static vector<ll> try_one(int N, ll X, vector<ll> &v)
{
X = X * 2 + 0;
ll ct = 0;
vector<ll> d(N, 0);
REP(i, N)
{
ll a = (X & 1) > 0;
if(ct == 61 || i >= N - 1)d[i] = 0;
else if(v[i] && (!a || v[i + 1]))d[i] = 1, d[i + 1] = a,i += 1, ct += 1, X >>= 1;
else d[i] = 0;
}
if(ct == 61)fg = 1;
return d;
}
static vector<ll> try_two(int N, ll X, vector<ll> &v)
{
X = X * 2 + 1;
ll ct = 0;
vector<ll> d(N, 0);
REP(i, N)
{
ll a = (X & 1) > 0;
ll b = (X & 2) > 0;
if(ct == 61 || i >= N - 2)d[i] = 0;
else if(ct == 0 && v[i] && (!a || v[i + 1]))d[i] = 1, d[i + 1] = a,i += 1, ct += 1, X >>= 1;
else if(ct != 0 && v[i] && (!a || v[i + 1]) && (!b || v[i + 2]))d[i] = 1, d[i + 1] = a, d[i + 2] = b, i += 2, ct += 2, X >>= 2;
else d[i] = 0;
}
if(ct == 61)fg = 1;
return d;
}
void Anna( int N, long long X, int K, int P[] ){
vector<ll> v(N, 1);
REP(i, K)v[P[i]] = 0;
vector<ll> d;
fg = 0;
d = try_one(N, X, v);
if(!fg)d = try_two(N, X, v);
REP(i, N)Set(i, d[i]);
}
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i ++)
long long Bruno( int N, int A[] ){
ll n = N;
ll tt = 0, t = 1, tp = -1;
REP(i, n)
{
if(A[i])
{
if(tp == -1)tp = A[i + 1], i ++;
else if(tp == 0)tt += t * A[i + 1], t <<= 1, i ++;
else tt += t * A[i + 1] + (t * 2) * A[i + 2], t <<= 2, i += 2;
}
}
return tt;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |