Anonymous
Segfault при инициализации большого массива внутри структуры [дубликат]
Сообщение
Anonymous » 06 авг 2024, 03:37
У меня есть следующий код (решает проблему подсчета подмассивов с помощью XOR >= k, но это не имеет особого значения):
Код: Выделить всё
#include
using namespace std;
#define ll long long
#define vi vector
#define rep(i, n) for(int i=0;i=0;i--)
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const int MAXN = 1000010, INDEXMULT = 33, BITS = 32;
struct XorTrie {
int go[INDEXMULT * MAXN][2], cnt[INDEXMULT * MAXN], sz;
void reset(bool full) {
int maxReset = full ? INDEXMULT * MAXN : min(sz + 2, INDEXMULT * MAXN);
rep(i, maxReset) go[i][0] = go[i][1] = cnt[i] = 0;
sz = 2;
}
void insert(int num) {
int curV = 1;
reprv(i, BITS) {
bool iSet = (num & (1
Подробнее здесь: [url]https://stackoverflow.com/questions/78836792/segfault-on-initializing-large-array-inside-a-struct[/url]
1722904628
Anonymous
У меня есть следующий код (решает проблему подсчета подмассивов с помощью XOR >= k, но это не имеет особого значения): [code]#include using namespace std; #define ll long long #define vi vector #define rep(i, n) for(int i=0;i=0;i--) #define IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) const int MAXN = 1000010, INDEXMULT = 33, BITS = 32; struct XorTrie { int go[INDEXMULT * MAXN][2], cnt[INDEXMULT * MAXN], sz; void reset(bool full) { int maxReset = full ? INDEXMULT * MAXN : min(sz + 2, INDEXMULT * MAXN); rep(i, maxReset) go[i][0] = go[i][1] = cnt[i] = 0; sz = 2; } void insert(int num) { int curV = 1; reprv(i, BITS) { bool iSet = (num & (1 Подробнее здесь: [url]https://stackoverflow.com/questions/78836792/segfault-on-initializing-large-array-inside-a-struct[/url]