Submission #761452

# Submission time Handle Problem Language Result Execution time Memory
761452 2023-06-19T16:34:25 Z ksu2009en Brperm (RMI20_brperm) C++17
50 / 100
3000 ms 1908 KB
#include "brperm.h"
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>

using namespace std;
typedef long long ll;

ll inv(ll n, ll sz){
    if(sz == 0)
        return 0;
    
    string a;
    
    for(int i = sz - 1; i >= 0; i--){
        if((n >> i) % 2 != 0)
            a += "1";
        else
            a += "0";
    }
        
    reverse(a.begin(), a.end());
    
    ll n2 = 0, j = 0;
    
    for(int i = sz - 1; i >= 0; i--){
        if(a[j] == '1')
            n2 += (1 << i);
        
        j++;
    }
    
    return n2;
}

string a;

ll N;

void init(int n, const char s[]) {
    N = n;
    for(int i = 0; i < n; i++)
        a.push_back(s[i]);
    
    return;
}


int query(int l, int k) {
    if(l + (1 << k) - 1 > N)
        return 0;
    
    for(int i = 0; i < (1 << k); i++)
        if(a[l + i] != a[l + inv(i, k)])
            return 0;
    
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 38 ms 748 KB Output is correct
4 Correct 40 ms 1672 KB Output is correct
5 Correct 32 ms 1684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3048 ms 1908 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 212 KB Output is correct
3 Correct 38 ms 748 KB Output is correct
4 Correct 40 ms 1672 KB Output is correct
5 Correct 32 ms 1684 KB Output is correct
6 Execution timed out 3048 ms 1908 KB Time limit exceeded
7 Halted 0 ms 0 KB -