답안 #597030

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597030 2022-07-15T12:06:24 Z Hacv16 Brperm (RMI20_brperm) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
const int MAX = 100010;
const int LOG = 18;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
 
#define pb push_back
#define sz(x) (int) x.size()
#define fr first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define dbg(x) cout << #x << ": " << "[ " << x << " ]\n"
 
string s, ans[MAX][LOG];
 
map<pii, string> memo;

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
const int MAX = 100010;
const int LOG = 18;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
 
#define pb push_back
#define sz(x) (int) x.size()
#define fr first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define dbg(x) cout << #x << ": " << "[ " << x << " ]\n"
 
string s, ans[MAX][LOG];
 
map<pii, string> memo;

int query(int I, int K){
    if(I + (1 << K) > sz(s)) return 0;
    string aux = s.substr(I, (1 << K));
    return aux == ans[I][K];
}

void init(int n, const char S[]){
    for(int i = 0; i < n; i++)
        s += S[i], ans[i][0] = S[i];
 
    for(int j = 1; j < LOG; j++){
        for(int i = 0; i + (1 << j) <= n; i++){
            for(int k = 0; k < min(sz(ans[i][j - 1]), sz(ans[i + (1 << (j - 1))][j - 1])); k++){
                ans[i][j] += ans[i][j - 1][k];
                ans[i][j] += ans[i + (1 << (j - 1))][j - 1][k];
            }

            //cout << ans[i][j] << '\n';
        }
    }
}

void init(int n, const char S[]){
    for(int i = 0; i < n; i++)
        s += S[i], ans[i][0] = S[i];
 
    for(int j = 1; j < LOG; j++){
        for(int i = 0; i + (1 << j) <= n; i++){
            for(int k = 0; k < min(sz(ans[i][j - 1]), sz(ans[i + (1 << (j - 1))][j - 1])); k++){
                ans[i][j] += ans[i][j - 1][k];
                ans[i][j] += ans[i + (1 << (j - 1))][j - 1][k];
            }

            //cout << ans[i][j] << '\n';
        }
    }
}

Compilation message

brperm.cpp:30:11: error: redefinition of 'const int MAX'
   30 | const int MAX = 100010;
      |           ^~~
brperm.cpp:7:11: note: 'const int MAX' previously defined here
    7 | const int MAX = 100010;
      |           ^~~
brperm.cpp:31:11: error: redefinition of 'const int LOG'
   31 | const int LOG = 18;
      |           ^~~
brperm.cpp:8:11: note: 'const int LOG' previously defined here
    8 | const int LOG = 18;
      |           ^~~
brperm.cpp:32:11: error: redefinition of 'const int INF'
   32 | const int INF = 0x3f3f3f3f;
      |           ^~~
brperm.cpp:9:11: note: 'const int INF' previously defined here
    9 | const int INF = 0x3f3f3f3f;
      |           ^~~
brperm.cpp:33:11: error: redefinition of 'const int MOD'
   33 | const int MOD = 1e9 + 7;
      |           ^~~
brperm.cpp:10:11: note: 'const int MOD' previously defined here
   10 | const int MOD = 1e9 + 7;
      |           ^~~
brperm.cpp:43:8: error: redefinition of 'std::string s'
   43 | string s, ans[MAX][LOG];
      |        ^
brperm.cpp:20:8: note: 'std::string s' previously declared here
   20 | string s, ans[MAX][LOG];
      |        ^
brperm.cpp:43:11: error: redefinition of 'std::string ans [100010][18]'
   43 | string s, ans[MAX][LOG];
      |           ^~~
brperm.cpp:20:11: note: 'std::string ans [100010][18]' previously declared here
   20 | string s, ans[MAX][LOG];
      |           ^~~
brperm.cpp:45:18: error: redefinition of 'std::map<std::pair<int, int>, std::__cxx11::basic_string<char> > memo'
   45 | map<pii, string> memo;
      |                  ^~~~
brperm.cpp:22:18: note: 'std::map<std::pair<int, int>, std::__cxx11::basic_string<char> > memo' previously declared here
   22 | map<pii, string> memo;
      |                  ^~~~
brperm.cpp:69:6: error: redefinition of 'void init(int, const char*)'
   69 | void init(int n, const char S[]){
      |      ^~~~
brperm.cpp:53:6: note: 'void init(int, const char*)' previously defined here
   53 | void init(int n, const char S[]){
      |      ^~~~