답안 #494369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494369 2021-12-15T10:46:16 Z jasen_penchev Brperm (RMI20_brperm) C++14
50 / 100
3000 ms 2668 KB
#include "brperm.h"
#include <iostream>
#include <string>
#define endl '\n'
using namespace std;

string str = "";

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

int query(int pos, int k)
{
    if (pos + (1ll << k) > str.size()) return 0;

    for (int i = 0; i < (1ll << k); ++ i)
    {
        int idx = 0;
        for (int j = 0; j < k; ++ j)
        {
            if ((i & (1ll << j))) idx += (1ll << (k - j - 1));
        }

        if (str[pos + i] != str[pos + idx]) return 0;
    }

    return 1;
}

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:20:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     if (pos + (1ll << k) > str.size()) return 0;
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 28 ms 1728 KB Output is correct
4 Correct 27 ms 1604 KB Output is correct
5 Correct 28 ms 1740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3045 ms 2668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 28 ms 1728 KB Output is correct
4 Correct 27 ms 1604 KB Output is correct
5 Correct 28 ms 1740 KB Output is correct
6 Execution timed out 3045 ms 2668 KB Time limit exceeded
7 Halted 0 ms 0 KB -