Блог пользователя Ahmed_Mostafa

Автор Ahmed_Mostafa, история, 7 лет назад, По-английски

I was trying to solve a problem using c++ regex class but a runtime error occurred. I printed the exception and it was : "Number of NFA states exceeds limit. Please use shorter regex string, or use smaller brace expression, or make larger." (submission : http://mirror.codeforces.com/contest/832/submission/29048936)

the macro _GLIBCXX_REGEX_STATE_LIMIT is defined here: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/regex_automaton.h

as #define _GLIBCXX_REGEX_STATE_LIMIT 100000

For the specific problem I was trying to solve the pattern string I had to construct can exceed 100000 chars and so maybe when it gets converted to a NFA it will need more states,of course this is an internal header file and we don't have access to it so I can't include it and undefine the macro and redefine it with another limit.

Does anyone know how to change this limit ? the exception message clearly said "or make _GLIBCXX_REGEX_STATE_LIMIT larger." so there should be a way to change that limit.

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

»
7 лет назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

It says

#ifndef _GLIBCXX_REGEX_STATE_LIMIT
#define _GLIBCXX_REGEX_STATE_LIMIT 100000
#endif

So just define the macro at the top of your program.