Submission #645765

# Submission time Handle Problem Language Result Execution time Memory
645765 2022-09-28T00:12:51 Z rodov Brperm (RMI20_brperm) C++14
Compilation error
0 ms 0 KB
#include "brperm.h"

int n;
char* str;

inline int Mpow2(int x) {
  return (1 << x);
}

int rot(int x, int k) {
  int ans = 0;

  for (int i = 0; i < k; i++)
    if ((x >> i) & 1)
      ans |= (1 << (k - 1 - i));
  
  return ans;
}

void init(int l, const char s[]) {
  n = l;
  str = s;
}

int query(int s, int k) {
  if (s + Mpow2(k) - 1 >= n) return 0;

  for (int i = s; i < s + Mpow2(k); i++)
    if (str[i] != str[s + rot(i - s, k)])
      return 0;

  return 1;
}

Compilation message

brperm.cpp: In function 'void init(int, const char*)':
brperm.cpp:22:9: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
   22 |   str = s;
      |         ^
      |         |
      |         const char*