#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2")
#include "brperm.h"
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef int ll;
ll inv(ll n, ll sz){
string a;
for(int i = sz - 1; i >= 0; i--){
if((n >> i) % 2 != 0)
a += "1";
else
a += "0";
}
reverse(a.begin(), a.end());
ll c = sz - a.size();
for(int i = 0; i < c; i++)
a += "0";
ll n2 = 0, j = 0;
for(int i = sz - 1; i >= 0; i--){
if(a[j] == '1')
n2 += (1 << i);
j++;
}
return n2;
}
vector<pair<ll, ll>> d[20];
string a;
ll mp[500007][20];
ll N;
void init(int n, const char s[]) {
N = n;
for(int sz = 0; sz <= 19; sz++){
for(int i = 0; i < (1 << sz); i++){
if(inv(i, sz) > i){
d[sz].push_back({i, inv(i, sz)});
}
}
for(int i = 0; i <= n; i++)
mp[i][sz] = -1;
}
for(int i = 0; i < n; i++)
a.push_back(s[i]);
return;
}
int query(int l, int k) {
if(l + (1 << k) - 1 > N)
return 0;
if(mp[l][k] != -1)
return mp[l][k];
for(auto i: d[k]){
if(a[l + i.first] != a[l + i.second])
return mp[l][k] = 0;
}
return mp[l][k] = 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
205 ms |
4724 KB |
Output is correct |
2 |
Correct |
213 ms |
4788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
205 ms |
4724 KB |
Output is correct |
2 |
Correct |
213 ms |
4788 KB |
Output is correct |
3 |
Correct |
235 ms |
12768 KB |
Output is correct |
4 |
Correct |
235 ms |
12692 KB |
Output is correct |
5 |
Correct |
268 ms |
12812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2706 ms |
46556 KB |
Output is correct |
2 |
Correct |
416 ms |
46548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
205 ms |
4724 KB |
Output is correct |
2 |
Correct |
213 ms |
4788 KB |
Output is correct |
3 |
Correct |
235 ms |
12768 KB |
Output is correct |
4 |
Correct |
235 ms |
12692 KB |
Output is correct |
5 |
Correct |
268 ms |
12812 KB |
Output is correct |
6 |
Correct |
2706 ms |
46556 KB |
Output is correct |
7 |
Correct |
416 ms |
46548 KB |
Output is correct |
8 |
Correct |
434 ms |
46576 KB |
Output is correct |
9 |
Correct |
429 ms |
46524 KB |
Output is correct |
10 |
Correct |
424 ms |
46432 KB |
Output is correct |