답안 #755113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755113 2023-06-09T12:11:38 Z Stickfish Brperm (RMI20_brperm) C++17
50 / 100
3000 ms 1908 KB
#include "brperm.h"
#include <iostream>
#include <vector>
using namespace std;

int rvs_pos(int i, int k) {
    int ans = 0;
    for (int bt = 0; bt < k; ++bt) if (i & (1 << bt)) {
        ans += 1 << (k - bt - 1);
    }
    return ans;
}

string s;

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

int query(int l, int k) {
    if (l + (1 << k) > s.size())
        return 0;
    vector<char> a(1 << k);
    vector<char> b(1 << k);
    for (int i = 0; i < (1 << k); ++i) {
        //cout << rvs_pos(i, k) << "(" << s[l + i] << ' ' << s[l + rvs_pos(i, k)] << ") ";
        if (s[l + i] != s[l + rvs_pos(i, k)]) {
            return 0;
        }
    }
    //cout << endl;
    return 1;

}

Compilation message

brperm.cpp: In function 'int query(int, int)':
brperm.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     if (l + (1 << k) > s.size())
      |         ~~~~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 45 ms 1312 KB Output is correct
4 Correct 46 ms 1776 KB Output is correct
5 Correct 45 ms 1784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3063 ms 1908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 45 ms 1312 KB Output is correct
4 Correct 46 ms 1776 KB Output is correct
5 Correct 45 ms 1784 KB Output is correct
6 Execution timed out 3063 ms 1908 KB Time limit exceeded
7 Halted 0 ms 0 KB -