# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310976 | Lawliet | Broken Device (JOI17_broken_device) | C++17 | 56 ms | 3328 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;
const int MAXN = 200;
int ans[MAXN];
bool blocked[MAXN];
vector<int> bits;
void Anna(int N, long long X, int K, int P[])
{
bits.clear();
memset( ans , 0 , sizeof(ans) );
memset( blocked , false , sizeof(blocked) );
for(int i = 0 ; i < K ; i++)
blocked[ P[i] ] = true;
for(int i = 0 ; i < 150 ; i++)
bits.push_back( X%2 ), X /= 2;
for(int i = 0 ; i < N ; i += 3)
{
int optQtd = 0;
//Ver se consigo enviar 1
if( bits[0] == 1 && !blocked[i + 2] ) optQtd = 1;
if( bits[0] == 0 && !blocked[i + 1] ) optQtd = 1;
if( bits[0] == 0 && !blocked[i] && !blocked[i + 2] ) optQtd = 1;
//Ver se consigo enviar 2
if( bits[0] == 0 && bits[1] == 0 && !blocked[i + 1] && !blocked[i + 2] ) optQtd = 2;
if( bits[0] == 0 && bits[1] == 1 && !blocked[i] && !blocked[i + 1] && !blocked[i + 2] ) optQtd = 2;
if( bits[0] == 1 && bits[1] == 0 && !blocked[i] ) optQtd = 2;
if( bits[0] == 1 && bits[1] == 1 && !blocked[i] && !blocked[i + 1] ) optQtd = 2;
if( optQtd == 0 ) continue;
if( optQtd == 2 )
{
if( bits[0] == 0 && bits[1] == 0 ) ans[i + 1] = ans[i + 2] = 1;
if( bits[0] == 0 && bits[1] == 1 ) ans[i] = ans[i + 1] = ans[i + 2] = 1;
if( bits[0] == 1 && bits[1] == 0 ) ans[i] = 1;
if( bits[0] == 1 && bits[1] == 1 ) ans[i] = ans[i + 1] = 1;
bits.erase( bits.begin() );
bits.erase( bits.begin() );
continue;
}
if( bits[0] == 1 ) ans[i + 2] = 1;
else
{
if( !blocked[i + 1] ) ans[i + 1] = 1;
else ans[i] = ans[i + 2] = 1;
}
bits.erase( bits.begin() );
}
for(int i = 0 ; i < N ; i++)
Set( i , ans[i] );
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
long long Bruno(int N, int A[])
{
lli ans = 0;
for(int i = N - 3 ; i >= 0 ; i -= 3)
{
//if( A[i] == 0 && A[i + 1] == 0 && A[i + 2] == 0 )
if( A[i] == 0 && A[i + 1] == 0 && A[i + 2] == 1 ) ans *= 2, ans += 1;
if( A[i] == 0 && A[i + 1] == 1 && A[i + 2] == 0 ) ans *= 2, ans += 0;
if( A[i] == 0 && A[i + 1] == 1 && A[i + 2] == 1 ) ans *= 4, ans += 0;
if( A[i] == 1 && A[i + 1] == 0 && A[i + 2] == 0 ) ans *= 4, ans += 1;
if( A[i] == 1 && A[i + 1] == 0 && A[i + 2] == 1 ) ans *= 2, ans += 0;
if( A[i] == 1 && A[i + 1] == 1 && A[i + 2] == 0 ) ans *= 4, ans += 3;
if( A[i] == 1 && A[i + 1] == 1 && A[i + 2] == 1 ) ans *= 4, ans += 2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |