Submission #493629

# Submission time Handle Problem Language Result Execution time Memory
493629 2021-12-12T12:14:33 Z Jeff12345121 Brperm (RMI20_brperm) C++14
50 / 100
3000 ms 81008 KB
#include <bits/stdc++.h>
#include "brperm.h"
using namespace std;



const int nmax = 500005;
int n;
char c[nmax];
int revpre[nmax][20];
int rev(int x, int k) {
    int res = 0,cnt = 0;
    for (int i = k - 1; i >= 0; i--) {
        if (x & (1 << i)) res += (1 << cnt);
        cnt++;
    }
    return res;
}
void init(int N, const char C[]) {
    n = N;
    for (int k = 0; k < 20; k++) {
        for (int i = 0; i < n; i++) {
            revpre[i][k] = rev(i,k);
        }
    }
    for (int i = 0; i < N; i++) {
        c[i] = C[i];
    }
}

int qpre[nmax][20];
int query(int i, int k) {
    if (i + (1 << k) - 1 >= n) return 0;
    if (qpre[i][k] != 0) return qpre[i][k] - 1;

    int limit = i + (1 << (k - 1)) - 1;
    for (int j = i; j <= limit; j++) {
        if (c[j] != c[revpre[j - i][k] + i]) return (qpre[i][k] = 1) - 1;
    }
    return (qpre[i][k] = 2) - 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 82 ms 16304 KB Output is correct
4 Correct 80 ms 16336 KB Output is correct
5 Correct 79 ms 16300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 81008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 82 ms 16304 KB Output is correct
4 Correct 80 ms 16336 KB Output is correct
5 Correct 79 ms 16300 KB Output is correct
6 Execution timed out 3084 ms 81008 KB Time limit exceeded
7 Halted 0 ms 0 KB -