답안 #857250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857250 2023-10-05T16:37:01 Z divad Brperm (RMI20_brperm) C++14
컴파일 오류
0 ms 0 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;
}

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

Compilation message

brperm.cpp:19:6: error: ambiguating new declaration of 'bool query(int, int)'
   19 | bool query(int pos, int k){
      |      ^~~~~
In file included from brperm.cpp:2:
brperm.h:5:5: note: old declaration 'int query(int, int)'
    5 | int query(int i, int k);
      |     ^~~~~