Submission #232806

# Submission time Handle Problem Language Result Execution time Memory
232806 2020-05-18T08:32:13 Z AlexLuchianov Broken Device (JOI17_broken_device) C++14
100 / 100
72 ms 3328 KB
#include "Annalib.h"
#include <iostream>

using ll = long long;
  namespace Alice{
  int const nmax = 150;
  int const modulo = 1000000007;
  int const base = 23;
  int const rest = 7;


  int block[1 + nmax];
  int v[1 + nmax];

  int root;

  int myrand(){
    root = (1LL * root * base + rest) % modulo;
    return root;
  }

  void staticshuffle(int n){
    for(int i = 0; i < n; i++)
      v[i] = i;
    for(int i = 0; i < 3 * n; i++){
      int x = myrand() % n;
      int y = myrand() % n;

      std::swap(v[x], v[y]);
    }
  }
}
using namespace Alice;

void Anna( int n, long long X, int k, int P[] ){
  root = 1;
  staticshuffle(n);

  for(int i = 0; i < n; i++)
    block[i] = 1;

  for(int i = 0; i < k; i++)
    block[P[i]] = 0;

  for(int i = 0; i < n; i += 2){
    int number = X % 3 + 1;
    int x = (0 < (number & 2));
    int y = (number & 1);

    if(0 < X && x <= block[v[i]] && y <= block[v[i + 1]]) {
      X /= 3;
      Set(v[i], x);
      Set(v[i + 1], y);
    } else {
      Set(v[i], 0);
      Set(v[i + 1], 0);
    }
  }
}
#include "Brunolib.h"
#include <iostream>

using ll = long long;

namespace Ban{
  int const nmax = 150;
  int const modulo = 1000000007;
  int const base = 23;
  int const rest = 7;

  int v[1 + nmax];

  int root;

  int myrand(){
    root = (1LL * root * base + rest) % modulo;
    return root;
  }

  void staticshuffle(int n){
    for(int i = 0; i < n; i++)
      v[i] = i;
    for(int i = 0; i < 3 * n; i++){
      int x = myrand() % n;
      int y = myrand() % n;
      std::swap(v[x], v[y]);
    }
  }
}
using namespace Ban;

long long Bruno(int n, int A[] ){
  root = 1;
  staticshuffle(n);

  ll result = 0;
  for(int i = n - 2; 0 <= i; i -= 2){
    if(A[v[i]] == 0 && A[v[i + 1]] == 0) {
      continue;
    } else {
      int number = (A[v[i]]<<1) + A[v[i + 1]] - 1;
      result = result * 3 + number;
    }
  }
  return result;
}
# Verdict Execution time Memory Grader output
1 Correct 68 ms 3056 KB Output is correct - L* = 40
2 Correct 66 ms 3056 KB Output is correct - L* = 40
3 Correct 65 ms 3056 KB Output is correct - L* = 40
4 Correct 65 ms 3072 KB Output is correct - L* = 40
5 Correct 66 ms 3056 KB Output is correct - L* = 40
6 Correct 67 ms 2800 KB Output is correct - L* = 40
7 Correct 66 ms 3056 KB Output is correct - L* = 40
8 Correct 67 ms 3056 KB Output is correct - L* = 40
9 Correct 68 ms 3056 KB Output is correct - L* = 40
10 Correct 67 ms 3072 KB Output is correct - L* = 40
11 Correct 65 ms 3056 KB Output is correct - L* = 40
12 Correct 68 ms 3056 KB Output is correct - L* = 40
13 Correct 65 ms 3056 KB Output is correct - L* = 40
14 Correct 65 ms 3072 KB Output is correct - L* = 40
15 Correct 65 ms 3056 KB Output is correct - L* = 40
16 Correct 65 ms 3056 KB Output is correct - L* = 40
17 Correct 67 ms 3040 KB Output is correct - L* = 40
18 Correct 66 ms 3056 KB Output is correct - L* = 40
19 Correct 68 ms 3056 KB Output is correct - L* = 40
20 Correct 67 ms 3056 KB Output is correct - L* = 40
21 Correct 72 ms 3056 KB Output is correct - L* = 40
22 Correct 65 ms 3056 KB Output is correct - L* = 40
23 Correct 68 ms 3328 KB Output is correct - L* = 40
24 Correct 65 ms 3056 KB Output is correct - L* = 40
25 Correct 68 ms 3056 KB Output is correct - L* = 40
26 Correct 65 ms 3072 KB Output is correct - L* = 40
27 Correct 65 ms 3056 KB Output is correct - L* = 40
28 Correct 68 ms 3072 KB Output is correct - L* = 40
29 Correct 66 ms 3056 KB Output is correct - L* = 40
30 Correct 65 ms 3072 KB Output is correct - L* = 40
31 Correct 65 ms 3056 KB Output is correct - L* = 40
32 Correct 69 ms 3056 KB Output is correct - L* = 40
33 Correct 65 ms 3072 KB Output is correct - L* = 40
34 Correct 65 ms 3072 KB Output is correct - L* = 40
35 Correct 65 ms 3056 KB Output is correct - L* = 40
36 Correct 66 ms 3056 KB Output is correct - L* = 40
37 Correct 66 ms 3104 KB Output is correct - L* = 40
38 Correct 66 ms 3072 KB Output is correct - L* = 40
39 Correct 66 ms 3072 KB Output is correct - L* = 40
40 Correct 69 ms 3056 KB Output is correct - L* = 40