# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
755146 |
2023-06-09T12:47:47 Z |
Stickfish |
Brperm (RMI20_brperm) |
C++17 |
|
3000 ms |
16572 KB |
#include "brperm.h"
#include <iostream>
#include <vector>
using namespace std;
int rvs_pos(int i, int k) {
int ans = 0;
for (int bt = 0; bt < k; ++bt) if (i & (1 << bt)) {
ans += 1 << (k - bt - 1);
}
return ans;
}
int n;
string s;
vector<int> blocks[20];
struct segment {
int layer;
int mod;
int l;
segment() {}
segment(int layer_, int mod_, int l_): layer(layer_), mod(mod_), l(l_) {}
int to_int() {
return blocks[layer][mod] + l;
}
segment operator+(const int& x) const {
return {layer, mod, l + x};
}
segment sub_even() {
if (l % 2) {
return {
layer + 1,
mod + (1 << layer),
l / 2
};
} else {
return {
layer + 1,
mod,
l / 2
};
}
}
segment sub_odd() {
if (l % 2) {
return {
layer + 1,
mod,
l / 2 + 1
};
} else {
return {
layer + 1,
mod + (1 << layer),
l / 2
};
}
}
};
void init(int n0, const char s0[]) {
n = n0;
s = "";
for (int bl = 0; (1 << bl) <= n; ++bl) {
for (int mod = 0; mod < (1 << bl); ++mod) {
blocks[bl].push_back(s.size());
for (int i = mod; i < n; i += (1 << bl))
s.push_back(s0[i]);
}
}
}
bool get_ans(segment a, segment b, int k) {
if (k == 0)
return s[a.to_int()] == s[b.to_int()];
bool even = get_ans(a.sub_even(), b, k - 1);
bool odd = get_ans(a.sub_odd(), b + (1 << (k - 1)), k - 1);
return even & odd;
}
int query(int l, int k) {
if (l + (1 << k) > n)
return 0;
return get_ans({0, 0, l}, {0, 0, l}, k);
for (int i = 0; i < (1 << k); ++i) {
if (s[l + i] != s[l + rvs_pos(i, k)]) {
return 0;
}
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
3076 ms |
2908 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3037 ms |
16572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
3076 ms |
2908 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |