Submission #899453

# Submission time Handle Problem Language Result Execution time Memory
899453 2024-01-06T08:12:27 Z rajkon cmp (balkan11_cmp) C++14
73 / 100
1014 ms 107140 KB
#include "cmp.h"
#include <iostream>

int offset[6] {1, 4097, 5121, 5377, 5441, 5457};

void remember(int n) {
  for (int i = 0; i < 6; i++) {
    int address = (n >> 2*i) + offset[i];
    bit_set(address);
  } 
}

int compare(int b) {
  for (int i = 5; i >= 0; i--) {
    int address = (b >> 2*i) + offset[i];
    if (!bit_get(address)) {
      int last_d = 3 & (b >> (2*i));
      int prefix = (b >> (2*(i+1))) << 2;
      if (last_d == 0) return -1;
      if (last_d == 3) return 1;
      else if (last_d == 1) {
        if (bit_get(prefix + offset[i])) return 1;
        else return -1;
      } else {
        if (bit_get(prefix+3 + offset[i])) return -1;
        else return 1;
      }
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 1014 ms 107140 KB Output is partially correct - maxAccess = 13, score = 73