Submission #858140

# Submission time Handle Problem Language Result Execution time Memory
858140 2023-10-07T13:13:38 Z iulia_morariu Brperm (RMI20_brperm) C++14
50 / 100
3000 ms 1024 KB
#include <bits/stdc++.h>
#include <brperm.h>

using namespace std;
char v[100000];
int n;

void init ( int N,  const char s[] ){
    n = N;
    for(int i = 0; i < n; i++) v[i] = 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 n1 = 0;
    int p = 1;
    for(int j = k - 1; j >= 0; j--){
        n1 += p * b[j];
        p *= 2;
    }
    return n1;
}

int query ( int it , int k ){
    int p = 1;
    for(int i = 0; i < k; i++) p *= 2;

    if(it + p > n) return 0;

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

Compilation message

brperm.cpp: In function 'int transform(int, int)':
brperm.cpp:19:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while(b.size() < k) b.push_back(0);
      |           ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 41 ms 724 KB Output is correct
4 Correct 46 ms 976 KB Output is correct
5 Correct 39 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3048 ms 1024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 41 ms 724 KB Output is correct
4 Correct 46 ms 976 KB Output is correct
5 Correct 39 ms 736 KB Output is correct
6 Execution timed out 3048 ms 1024 KB Time limit exceeded
7 Halted 0 ms 0 KB -