답안 #494508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494508 2021-12-15T16:26:08 Z leaked Brperm (RMI20_brperm) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define m_p make_pair
#define vec vector
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fast_rmi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
const int N=(1<<19);
int pref[N][26];
int work[N][20];

int answ[N][20];
string s;
void init(int n,const char t[]){
    for(int i=0;i<n;i++){
        s+=t[i];
        for(int j=0;j<26;j++){
            pref[i][j]=(i?pref[i-1][j]:0);
        }
        pref[i][s[i]-'a']++;
    }
    for(int j=1;j<20;j++){
        for(int i=0;i<(1<<j);i++){
            ///TODO
            for(int k=0;k<j;k++){
                if((1<<k)&i)
                    work[i][j]+=(1<<(j-k-1));
            }
            answ[i][j]=-1;
        }
    }
}
int query(int i,int k){
    if(k>20 || i+(1<<(k-1))-1>=sz(s))
        return 0;
    if(answ[i][k]!=-1)
        return answ[i][k];
    int l=i,r=i+(1<<(k-1))-1;
    for(int j=0;j<26;j++){
        if((pref[r][j]-(l?pref[l-1][j]:0))==(r-l+1))
            return 1;
    }
    int ok=1;
    for(int i=l;i<=r;i++){
        int id=l+work[(i-l)][k];
        if(s[i]!=s[id]){
            ok=0;
            break;
        }
    }
    answ[i][k]=ok;
    return ok;
}
//char * a;
char a[2000];
signed main(){
//    char *a=new char[];
    cin>>a;
    int n=strlen(a);
    init(n,a);
    cout<<query(1,2);
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccAyfbkA.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccanuCgy.o:brperm.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status