답안 #478745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478745 2021-10-08T08:24:29 Z Tenis0206 Brperm (RMI20_brperm) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "brperm.h"

using namespace std;
char b[100005];
string s;
int query(int poz, int k)
{
    int l = (1<<k);
    if(poz+l-1>=s.size())
    {
        return 0;
    }
    for(int i=poz;i<=poz+l-1;i++)
    {
        int sim=0;
        for(int b=0;b<k;b++)
        {
            if((i-poz)&(1<<b))
            {
                sim+=(1<<(k-b-1));
            }
        }
        if(s[i]!=s[sim+poz])
        {
            return 0;
        }
    }
    return 1;
}
void init(int n, char a[])
{
    for(int i=0;i<n;i++)
    {
        s.push_back(a[i]);
    }
}

/*int main()
{
    freopen("nr.in","r",stdin);
    freopen("nr.out","w",stdout);
    int n,q;
    char s[1000005];
    cin>>n;
    cin>>s;
    init(n,s);
    cin>>q;
    for(int i=1;i<=q;i++)
    {
        int poz,k;
        cin>>poz>>k;
        cout<<query(poz,k)<<'\n';
    }
    return 0;
}
*/

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     if(poz+l-1>=s.size())
      |        ~~~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccHihEhu.o: in function `main':
grader.cpp:(.text.startup+0x72): undefined reference to `init(int, char const*)'
collect2: error: ld returned 1 exit status