#include <bits/stdc++.h>
#include <brperm.h>
using namespace std;
const int MAXN = 5e5 + 10;
int Roupas[MAXN], pos[MAXN];
int findK(int num)
{
for (int k = 20; k >= 0; k--) if (num & (1 << k)) return k;
}
int inv(int num, int K)
{
int resp = 0;
for (int k = K; k >= 0; k--) resp += (num & (1 << k)) ? (1 << (K - k)) : 0;
return resp;
}
int query(int X, int K)
{
int Y = X + (1 << K) - 1;
int maxK = findK(Y);
for (int i = 0; i <= Y-X; i++) pos[i-X] = inv(i - X, maxK);
for (int i = 0; i <= Y-X; i++) if (Roupas[i] != Roupas[pos[i]]) {return 0;}
return 1;
}
void init(int N, const char s[])
{
for (int i = 0; i < N; i++) Roupas[i] = s[i];
int K = findK(N-1);
for (int i = 0; i < N; i++) pos[i] = inv(i, K);
}
/*int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
init(4, "axxy");
cout << query(0, 2);
}*/
Compilation message
brperm.cpp: In function 'int findK(int)':
brperm.cpp:10:1: warning: control reaches end of non-void function [-Wreturn-type]
10 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1223 ms |
4564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1223 ms |
4564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
27 ms |
9292 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1223 ms |
4564 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |