답안 #1094813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094813 2024-09-30T15:46:14 Z alexdd Brperm (RMI20_brperm) C++17
50 / 100
3000 ms 2076 KB
#include "brperm.h"
#include <bits/stdc++.h>
using namespace std;
int n;
const long long MOD = 1e9+9;
long long p[530005];
int put(int a, int exp)
{
    if(exp==0)
        return 1;
    if(exp%2==0)
        return put(a*a%MOD,exp/2);
    else
        return put(a*a%MOD,exp/2)*a%MOD;
}
int rev(int x, int k)
{
    int aux=0;
    for(int i=0;i<k;i++)
        if(((1<<i)&x))
            aux += (1<<(k-i-1));
    return aux;
}
long long hsh[500005][19];
long long normal[500005][19];
char S[500005];
void init(int copn, const char s[])
{
    n=copn;
    for(int i=0;i<n;i++)
        S[i] = s[i];
    /*p[0]=1;
    p[1]=31;
    for(int i=2;i<=(1<<19);i++)
        p[i] = (p[i-1]*p[1])%MOD;

    for(int i=0;i<n;i++)
    {
        hsh[i][0] = normal[i][0] = S[i];
    }
    for(int k=1;k<19;k++)
    {
        for(int i=0;i+(1<<k)-1<n;i++)
        {
            hsh[i][k] = (hsh[i][k-1] + hsh[i+(1<<(k-1))][k-1]*p[(1<<(18-k))])%MOD;

            for(int j=0;j<(1<<k);j++)
            {
                normal[i][k] = (normal[i][k] + S[i+j]*p[j*(1<<(18-k))])%MOD;
            }

        }
    }*/
}

int query(int i, int k)
{
    if(i+(1<<k)-1 >= n)
        return 0;
    for(int j=0;j<(1<<k);j++)
        if(S[i+j]!=S[i+rev(j,k)])
            return 0;
    return 1;
    return hsh[i][k] == normal[i][k];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 31 ms 1628 KB Output is correct
4 Correct 18 ms 1628 KB Output is correct
5 Correct 18 ms 1624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3058 ms 2076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 31 ms 1628 KB Output is correct
4 Correct 18 ms 1628 KB Output is correct
5 Correct 18 ms 1624 KB Output is correct
6 Execution timed out 3058 ms 2076 KB Time limit exceeded
7 Halted 0 ms 0 KB -