結果

問題 No.1471 Sort Queries
ユーザー firiexpfiriexp
提出日時 2021-04-28 09:33:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 927 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 95,592 KB
最終ジャッジ日時 2024-04-27 03:45:48
合計ジャッジ時間 1,165 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:27:19: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 26> >, std::array<int, 26> >::value_type' {aka 'std::array<int, 26>'} and 'int')
   27 |             S[i+1][j] += S[i][j];
      |                   ^
main.cpp:27:30: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 26> >, std::array<int, 26> >::value_type' {aka 'std::array<int, 26>'} and 'int')
   27 |             S[i+1][j] += S[i][j];
      |                              ^
main.cpp:29:15: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 26> >, std::array<int, 26> >::value_type' {aka 'std::array<int, 26>'} and 'int')
   29 |         S[i+1][s[i]-'a']++;
      |               ^
main.cpp:36:22: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 26> >, std::array<int, 26> >::value_type' {aka 'std::array<int, 26>'} and 'int')
   36 |             x -= S[r][i]-S[l][i];
      |                      ^
main.cpp:36:30: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::array<int, 26> >, std::array<int, 26> >::value_type' {aka 'std::array<int, 26>'} and 'int')
   36 |             x -= S[r][i]-S[l][i];
      |                              ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/queue:61,
                 from main.cpp:5:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::array<int, 26>; _Alloc = std::allocator<std::array<int, 26> >; reference = std::array<int, 26>&; size_type = long unsigned int]':
main.

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<array<int, 26>> S(n+1);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 26; ++j) {
            S[i+1][j] += S[i][j];
        }
        S[i+1][s[i]-'a']++;
    }
    while(q--){
        int l, r, x;
        scanf("%d %d %d", &l, &r, &x);
        l--;
        for (int i = 0; i < 26; ++i) {
            x -= S[r][i]-S[l][i];
            if(x <= 0){
                printf("%c\n", i+'a');
                break;
            }
        }
    }
    return 0;
}
0