Submission #494813

# Submission time Handle Problem Language Result Execution time Memory
494813 2021-12-16T15:28:08 Z ovidiush11 Brperm (RMI20_brperm) C++14
0 / 100
3 ms 2392 KB
#include <bits/stdc++.h>
#include "brperm.h"
using namespace std;

std::string st;

void init(int n, const char s[])
{
    st = s;
    return;
}

int query(int i, int k)
{
    for(int j = 0;j < pow(2,k);j++)
    {
        string a;
        int n = j,p = k;
        while(n != 0)
        {
            if(n % 2 == 1)a+='1';
            else a+='0';
            n/=2;
        }
        int x = a.size();
        while(x != k){a+='0';x++;}
        n = 0;
        int y = 0;
        while(y < x)
        {
            if(a[y] == '1')n += pow(2,x-y-1);
            y++;
        }
        if(st[i+j] != st[i+n])return 0;
    }
    return 1;
}

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:18:19: warning: unused variable 'p' [-Wunused-variable]
   18 |         int n = j,p = k;
      |                   ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 2392 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -