답안 #857258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857258 2023-10-05T16:54:16 Z divad Brperm (RMI20_brperm) C++14
50 / 100
3000 ms 2004 KB
#include <bits/stdc++.h>
#include "brperm.h"
using namespace std;
string str;

void init(int n, const char s[]) {
  str = s;
}

int rev_bits(int x, int k){
    int ans = 0;
    for(int i = 0; i < k; i++){
        int bt = (x>>i)&1;
        ans += bt*(1<<(k-i-1));
    }
    return ans;
}

int query(int i, int k){
    int len = (1<<k);
    if(i+len > str.size()){
        return 0;
    }
    string sub = str.substr(i, len);
    for(int i = 0; i < len; i++){
        if(sub[i] != sub[rev_bits(i, k)]){
            return false;
        }
    }
    return true;
}

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:21:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if(i+len > str.size()){
      |        ~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 28 ms 1884 KB Output is correct
4 Correct 24 ms 1620 KB Output is correct
5 Correct 26 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3034 ms 2004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 28 ms 1884 KB Output is correct
4 Correct 24 ms 1620 KB Output is correct
5 Correct 26 ms 1668 KB Output is correct
6 Execution timed out 3034 ms 2004 KB Time limit exceeded
7 Halted 0 ms 0 KB -