Submission #21016

# Submission time Handle Problem Language Result Execution time Memory
21016 2017-03-29T14:52:22 Z model_code Broken Device (JOI17_broken_device) C++11
100 / 100
59 ms 2840 KB
#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




# Verdict Execution time Memory Grader output
1 Correct 28 ms 2840 KB Output is correct - L* = 40
2 Correct 35 ms 2840 KB Output is correct - L* = 40
3 Correct 38 ms 2840 KB Output is correct - L* = 40
4 Correct 32 ms 2840 KB Output is correct - L* = 40
5 Correct 28 ms 2840 KB Output is correct - L* = 40
6 Correct 26 ms 2840 KB Output is correct - L* = 40
7 Correct 41 ms 2840 KB Output is correct - L* = 40
8 Correct 35 ms 2840 KB Output is correct - L* = 40
9 Correct 35 ms 2840 KB Output is correct - L* = 40
10 Correct 35 ms 2840 KB Output is correct - L* = 40
11 Correct 35 ms 2840 KB Output is correct - L* = 40
12 Correct 35 ms 2840 KB Output is correct - L* = 40
13 Correct 35 ms 2840 KB Output is correct - L* = 40
14 Correct 35 ms 2840 KB Output is correct - L* = 40
15 Correct 32 ms 2840 KB Output is correct - L* = 40
16 Correct 35 ms 2840 KB Output is correct - L* = 40
17 Correct 56 ms 2840 KB Output is correct - L* = 40
18 Correct 35 ms 2840 KB Output is correct - L* = 40
19 Correct 28 ms 2840 KB Output is correct - L* = 40
20 Correct 32 ms 2840 KB Output is correct - L* = 40
21 Correct 32 ms 2840 KB Output is correct - L* = 40
22 Correct 32 ms 2840 KB Output is correct - L* = 40
23 Correct 35 ms 2840 KB Output is correct - L* = 40
24 Correct 35 ms 2840 KB Output is correct - L* = 40
25 Correct 38 ms 2840 KB Output is correct - L* = 40
26 Correct 32 ms 2840 KB Output is correct - L* = 40
27 Correct 35 ms 2840 KB Output is correct - L* = 40
28 Correct 32 ms 2840 KB Output is correct - L* = 40
29 Correct 32 ms 2840 KB Output is correct - L* = 40
30 Correct 28 ms 2840 KB Output is correct - L* = 40
31 Correct 35 ms 2840 KB Output is correct - L* = 40
32 Correct 26 ms 2840 KB Output is correct - L* = 40
33 Correct 39 ms 2840 KB Output is correct - L* = 40
34 Correct 59 ms 2840 KB Output is correct - L* = 40
35 Correct 32 ms 2840 KB Output is correct - L* = 40
36 Correct 32 ms 2840 KB Output is correct - L* = 40
37 Correct 32 ms 2840 KB Output is correct - L* = 40
38 Correct 41 ms 2840 KB Output is correct - L* = 40
39 Correct 39 ms 2840 KB Output is correct - L* = 40
40 Correct 32 ms 2840 KB Output is correct - L* = 40