/**
* author: milos
* created: 04.05.2021 20:27:22
**/
#include <bits/stdc++.h>
#include "brperm.h"
#pragma GCC optimize("O3")
using namespace std;
const int N = 500050;
string s = "";
vector<pair<int, int>> a(N);
void Calc(int n) {
for (int i = 0; i < n; i++) {
int j = i, cnt = 0, res = 0;
while (j) {
res = res * 2 + j % 2;
cnt++;
j /= 2;
}
a[i] = {res, cnt};
}
}
void init(int n, const char seq[]) {
for (int i = 0; i < n; i++) {
s += seq[i];
}
Calc(n);
}
int Rev(int x, int k) {
return a[x].first * (1 << (k - a[x].second));
}
int query(int i, int k) {
if (i + (1 << k) > (int) s.size()) {
return 0;
}
for (int j = i; j < i + (1 << k); j++) {
if (s[j] != s[i + Rev(j - i, k)]) {
return 0;
}
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4172 KB |
Output is correct |
2 |
Correct |
3 ms |
4172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4172 KB |
Output is correct |
2 |
Correct |
3 ms |
4172 KB |
Output is correct |
3 |
Correct |
30 ms |
5672 KB |
Output is correct |
4 |
Correct |
31 ms |
5644 KB |
Output is correct |
5 |
Correct |
30 ms |
5572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3080 ms |
9624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4172 KB |
Output is correct |
2 |
Correct |
3 ms |
4172 KB |
Output is correct |
3 |
Correct |
30 ms |
5672 KB |
Output is correct |
4 |
Correct |
31 ms |
5644 KB |
Output is correct |
5 |
Correct |
30 ms |
5572 KB |
Output is correct |
6 |
Execution timed out |
3080 ms |
9624 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |