Submission #1025079

# Submission time Handle Problem Language Result Execution time Memory
1025079 2024-07-16T15:36:28 Z TraianDanciu Broken Device (JOI17_broken_device) C++17
100 / 100
30 ms 3084 KB
#include "Annalib.h"
#include <algorithm>
#include <random>

#include <stdio.h>

#define MAXN 150
#define SEED 53702439
#define BAZA 3

void Anna(int n, long long x, int k, int p[]) {
  int i, cif, ok, poz[MAXN];
  std::mt19937 shuffler(SEED);
  char sterg[MAXN];
  
  for(i = 0; i < n; i++) {
    poz[i] = i;
    sterg[i] = 0;
  }
  std::shuffle(poz, poz + n, shuffler);

  for(i = 0; i < k; i++) {
    sterg[p[i]] = 1;
  }

  for(i = 0; i < n / 2; i++) {
    cif = x % BAZA;
    
    // 00 - nu folosim
    // 01 - cifra 0
    // 10 - cifra 1
    // 11 - cifra 2

    ok = 0;
    if(cif == 0 && sterg[poz[2 * i + 1]] == 0) {
      Set(poz[2 * i], 0);
      Set(poz[2 * i + 1], 1);
      ok = 1;
    } else if(cif == 1 && sterg[poz[2 * i]] == 0) {
      Set(poz[2 * i], 1);
      Set(poz[2 * i + 1], 0);
      ok = 1;
    } else if(cif == 2 && sterg[poz[2 * i]] == 0 && sterg[poz[2 * i + 1]] == 0) {
      Set(poz[2 * i], 1);
      Set(poz[2 * i + 1], 1);
      ok = 1;
    }

    if(ok == 0) {
      Set(poz[2 * i], 0);
      Set(poz[2 * i + 1], 0);
    } else {
      x /= BAZA;
    }
  }
}
#include "Brunolib.h"
#include <algorithm>
#include <random>

#define SEED 53702439
#define MAXN 150

long long Bruno(int n, int a[]) {
  int i, poz[MAXN];
  long long p3, x;
  std::mt19937 shuffler(SEED);

  for(i = 0; i < n; i++) {
    poz[i] = i;
  }
  std::shuffle(poz, poz + n, shuffler);

  p3 = 1;
  x = 0;
  for(i = 0; i < MAXN / 2; i++) {
    // 00 - nu folosim
    // 01 - cifra 0
    // 10 - cifra 1
    // 11 - cifra 2

    if(a[poz[2 * i]] == 1) {
      x += p3;
      if(a[poz[2 * i + 1]] == 1) {
        x += p3;
      }
    }

    if(a[poz[2 * i]] || a[poz[2 * i + 1]]) {
      p3 *= 3;
    }
  }

  return x;
}
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2764 KB Output is correct - L* = 40
2 Correct 27 ms 2824 KB Output is correct - L* = 40
3 Correct 30 ms 2796 KB Output is correct - L* = 40
4 Correct 28 ms 2768 KB Output is correct - L* = 40
5 Correct 27 ms 2924 KB Output is correct - L* = 40
6 Correct 26 ms 2772 KB Output is correct - L* = 40
7 Correct 25 ms 2860 KB Output is correct - L* = 40
8 Correct 25 ms 2752 KB Output is correct - L* = 40
9 Correct 25 ms 2712 KB Output is correct - L* = 40
10 Correct 28 ms 2752 KB Output is correct - L* = 40
11 Correct 25 ms 2772 KB Output is correct - L* = 40
12 Correct 25 ms 2772 KB Output is correct - L* = 40
13 Correct 25 ms 2648 KB Output is correct - L* = 40
14 Correct 25 ms 2832 KB Output is correct - L* = 40
15 Correct 26 ms 2748 KB Output is correct - L* = 40
16 Correct 25 ms 2896 KB Output is correct - L* = 40
17 Correct 25 ms 2684 KB Output is correct - L* = 40
18 Correct 26 ms 3084 KB Output is correct - L* = 40
19 Correct 25 ms 2676 KB Output is correct - L* = 40
20 Correct 27 ms 2780 KB Output is correct - L* = 40
21 Correct 24 ms 2748 KB Output is correct - L* = 40
22 Correct 25 ms 2664 KB Output is correct - L* = 40
23 Correct 25 ms 2768 KB Output is correct - L* = 40
24 Correct 25 ms 2840 KB Output is correct - L* = 40
25 Correct 25 ms 2768 KB Output is correct - L* = 40
26 Correct 27 ms 2836 KB Output is correct - L* = 40
27 Correct 26 ms 2852 KB Output is correct - L* = 40
28 Correct 26 ms 2768 KB Output is correct - L* = 40
29 Correct 25 ms 2768 KB Output is correct - L* = 40
30 Correct 24 ms 2768 KB Output is correct - L* = 40
31 Correct 27 ms 2816 KB Output is correct - L* = 40
32 Correct 26 ms 2836 KB Output is correct - L* = 40
33 Correct 26 ms 2840 KB Output is correct - L* = 40
34 Correct 30 ms 2652 KB Output is correct - L* = 40
35 Correct 27 ms 2768 KB Output is correct - L* = 40
36 Correct 26 ms 2768 KB Output is correct - L* = 40
37 Correct 27 ms 2772 KB Output is correct - L* = 40
38 Correct 26 ms 2736 KB Output is correct - L* = 40
39 Correct 26 ms 2744 KB Output is correct - L* = 40
40 Correct 27 ms 2832 KB Output is correct - L* = 40