제출 #858044

#제출 시각아이디문제언어결과실행 시간메모리
858044boris_mihovBrperm (RMI20_brperm)C++17
컴파일 에러
0 ms0 KiB
#include "brperm.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> typedef long long llong; const int MAXN = 500000 + 10; const int MOD = 1e9 + 7; const int MAXLOG = 20; int n; char s[MAXN]; int base[3 * MAXN]; struct Sparse { int normalHash[MAXN][MAXLOG]; int danceHash[MAXN][MAXLOG][MAXLOG]; void build() { for (int i = 0 ; i < n ; ++i) { normalHash[i][0] = s[i] - 'a' + 1; for (int lgH = 0 ; lgH < 2 * MAXLOG ; ++lgH) { danceHash[i][0][lgH] = s[i] - 'a' + 1; } } for (int lgLen = 1 ; (1 << lgLen) <= n ; ++lgLen) { for (int i = 0 ; i + (1 << lgLen) <= n ; ++i) { normalHash[i][lgLen] = (1LL * base[(1 << (lgLen - 1))] * normalHash[i][(lgLen - 1)] + normalHash[i + (1 << (lgLen - 1))][(lgLen - 1)]) % MOD; for (int lgH = 0 ; lgH + 1 < MAXLOG ; ++lgH) { danceHash[i][lgLen][lgH] = (1LL * base[1 << lgH] * danceHash[i][(lgLen - 1)][lgH + 1] + danceHash[i + (1 << (lgLen - 1))][(lgLen - 1)][lgH + 1]) % MOD; } } } } int query(int idx, int log) { return normalHash[idx][log] == danceHash[idx][log][0]; } }; Sparse sparse; void init(int N, const char S[]) { n = N; for (int i = 0 ; i < n ; ++i) { s[i] = S[i]; } base[0] = 1; for (int i = 1 ; i < 3 * MAXN ; ++i) { base[i] = (27LL * base[i - 1]) % MOD; } sparse.build(); } int query(int idx, int log) { return sparse.query(idx, log); }

컴파일 시 표준 에러 (stderr) 메시지

brperm.cpp: In member function 'void Sparse::build()':
brperm.cpp:29:38: warning: iteration 20 invokes undefined behavior [-Waggressive-loop-optimizations]
   29 |                 danceHash[i][0][lgH] = s[i] - 'a' + 1;
      |                 ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
brperm.cpp:27:36: note: within this loop
   27 |             for (int lgH = 0 ; lgH < 2 * MAXLOG ; ++lgH)
      |                                ~~~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccuCmyMa.o:(.bss+0x0): multiple definition of `s'; /tmp/ccRL2YT6.o:(.bss+0x326d31a0): first defined here
collect2: error: ld returned 1 exit status