# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
21016 | model_code | Broken Device (JOI17_broken_device) | C++11 | 59 ms | 2840 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 <cstdio>
static bool used[150];
static int cnt[150];
static int dat[150];
static int it;
static int ans[150];
void set_block( int i, int a, int b, int c ){
ans[i*3+0] = a;
ans[i*3+1] = b;
ans[i*3+2] = c;
}
void Anna( int N, long long X, int K, int P[] ){
it = 0;
for( int i = 0; i < N; i++ ){
used[i] = false;
cnt[i] = dat[i] = ans[i] = 0;
}
for( int i = 0; i < 60; i++ ){
dat[i] = X % 2;
X /= 2;
}
for( int i = 0; i < K; i++ ){
used[ P[i] ] = true;
cnt[ P[i] / 3 ]++;
}
for( int i = 0; i < N/3; i++ ){
if( cnt[i] == 0 ){
int c = dat[it] * 2 + dat[it+1];
if( c == 0 ){
set_block( i, 1, 0, 0 );
} else if( c == 1 ){
set_block( i, 1, 0, 1 );
} else if( c == 2 ){
set_block( i, 0, 1, 1 );
} else if( c == 3 ){
set_block( i, 1, 1, 1 );
}
it += 2;
} else if( cnt[i] == 1 ){
if( used[i*3+0] ){
if( dat[it] == 0 ){
set_block( i, 0, 1, 0 );
} else if( dat[it] == 1 ){
set_block( i, 0, 0, 1 );
}
it++;
} else if( used[i*3+1] ){
if( dat[it] == 1 ){
set_block( i, 0, 0, 1 );
it++;
} else if( dat[it+1] == 0 ){
set_block( i, 1, 0, 0 );
it += 2;
} else if( dat[it+1] == 1 ){
set_block( i, 1, 0, 1 );
it += 2;
}
} else if( used[i*3+2] ){
if( dat[it] == 0 ){
set_block( i, 0, 1, 0 );
} else if( dat[it] == 1 ){
set_block( i, 1, 1, 0 );
}
it++;
}
}
}
for( int i = 0; i < N; i++ ){
Set( i, ans[i] );
}
}
#include "Brunolib.h"
#include <cstdio>
static int it;
static int dat[150];
static const int len[] = { 0, 1, 1, 2, 2, 2, 1, 2 };
static const int val[] = { 0, 1, 0, 2, 0, 1, 1, 3 };
long long Bruno( int N, int A[] ){
it = 0;
for( int i = 0; i < N/3; i++ ){
int c = A[i*3+0] * 4 + A[i*3+1] * 2 + A[i*3+2];
if( len[c] == 1 ){
dat[it++] = val[c];
} else if( len[c] == 2 ){
dat[it++] = val[c] / 2;
dat[it++] = val[c] % 2;
}
}
long long d = 1;
long long ans = 0;
for( int i = 0; i < 60; i++ ){
ans += d * dat[i];
d *= 2;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |