답안 #596581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596581 2022-07-14T21:11:16 Z Deepesson Brperm (RMI20_brperm) C++17
50 / 100
33 ms 44128 KB
#include <bits/stdc++.h>
#define MAX 205000

void init(int n, const char s[]);
int query(int i, int k);
int prefsum[MAX][26];
int inverte(int x,int k){
    int ans=0;
    for(int i=0;i!=k;++i){
        int u = (k-1)-i;
        if((1<<i)&x)ans+=1<<u;
    }
    return ans;
}

int lim;
char vals[MAX];
void init(int n, const char s[]) {
    for(int j=0;j!=n;++j){
        vals[j]=s[j];
        for(int k=0;k!=26;++k){
            prefsum[j+1][k]=prefsum[j][k];
        }
        prefsum[j+1][s[j]-'a']++;
    }
    lim = n;
}
int count=0;
int query(int i, int k) {
    int sz = 1<<(k);
    if(i+sz>lim)return 0;
    int r=i+sz-1;
    for(int j=0;j!=sz;++j){
        int mirror = inverte(j,k);
        if(vals[mirror+i]!=vals[j+i])return 0;
        ++count;
        if(count==25000)break;
    }
    return 1;
}

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:32:9: warning: unused variable 'r' [-Wunused-variable]
   32 |     int r=i+sz-1;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 33 ms 10812 KB Output is correct
4 Correct 31 ms 10836 KB Output is correct
5 Correct 30 ms 10788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 44128 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 33 ms 10812 KB Output is correct
4 Correct 31 ms 10836 KB Output is correct
5 Correct 30 ms 10788 KB Output is correct
6 Runtime error 32 ms 44128 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -