Submission #858072

# Submission time Handle Problem Language Result Execution time Memory
858072 2023-10-07T11:39:18 Z iulia_morariu Brperm (RMI20_brperm) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <brperm.h>

using namespace std;

string v;
void init ( int n, char s[] ){
    for(int i = 0; i < n; i++) v.push_back( s[i] );
}

int transform(int nr, int k){
    vector <int> b;
    while(nr > 0){
        b.push_back(nr % 2);
        nr /= 2;
    }
    while(b.size() < k) b.push_back(0);

    int p = 1;
    for(int i = b.size() - 1; i >= 0; i--){
        nr += p * b[i];
        p *= 2;
    }
    return nr;
}

int query ( int it , int k ){
    int p = pow(2, k);
    for(int i = it; i < it + p; i++){
        int x = transform( i, k );
        //cout << "i = " << i << " x = " << x << endl;
        if( v[x] != v[i] ) return 0;
    }
    return 1;
}

Compilation message

brperm.cpp: In function 'int transform(int, int)':
brperm.cpp:17:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |     while(b.size() < k) b.push_back(0);
      |           ~~~~~~~~~^~~
/usr/bin/ld: /tmp/ccyrpNTj.o: in function `main':
grader.cpp:(.text.startup+0x72): undefined reference to `init(int, char const*)'
collect2: error: ld returned 1 exit status