Submission #596733

# Submission time Handle Problem Language Result Execution time Memory
596733 2022-07-15T02:21:24 Z definitelynotmee Brperm (RMI20_brperm) C++17
50 / 100
3000 ms 1632 KB
#include "brperm.h"
#include<bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
using matrix = vector<vector<T>>;
const ll INFL = 1ll<<60;
const int MOD = 1e9+7;

string S;

void init(int n, const char s[]) {

    S.resize(n);
    for(int i = 0; i < n; i++)
        S[i] = s[i];
    return;
}

int getreverse(int x, int k){
    int ret = 0;
    for(int i = 0; i < k; i++){
        ret+=(1<<i)*bool((1<<(k-i-1))&x);
    }
    return ret;
}

int query(int start, int k) {

    if(k == 0)
        return 1;


    bool ok = 1;
    if(start+(1<<k)>S.size())
        return 0;
        
    for(int i = 0; i < (1<<k); i++){
        //cout << k << ": " <<  bitset<4>(i-start) << ' ' << bitset<4>(getreverse(i-start,k)) << '\n';
        //assert(getreverse(i,k)+start < S.size());
        ok&=S[getreverse(i,k)+start] == S[i+start];
    }

    return ok;
}

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     if(start+(1<<k)>S.size())
      |        ~~~~~~~~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2443 ms 1528 KB Output is correct
4 Correct 2471 ms 1520 KB Output is correct
5 Correct 2413 ms 1632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3048 ms 1432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2443 ms 1528 KB Output is correct
4 Correct 2471 ms 1520 KB Output is correct
5 Correct 2413 ms 1632 KB Output is correct
6 Execution timed out 3048 ms 1432 KB Time limit exceeded
7 Halted 0 ms 0 KB -