結果

問題 No.1471 Sort Queries
コンテスト
ユーザー terry_u16
提出日時 2021-04-09 22:11:07
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.90.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 14 ms / 2,000 ms
+ 493µs
コード長 828 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,680 ms
コンパイル使用メモリ 133,376 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-29 16:09:59
合計ジャッジ時間 4,147 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <string>

int main()
{
    int n, queries;
    std::string s;

    std::cin >> n >> queries >> s;

    std::vector<std::vector<int>> counts(n + 1, std::vector<int>(26));

    for (size_t i = 0; i < s.length(); i++)
    {
        auto c = s[i] - 'a';
        counts[i + 1][c]++;

        for (size_t j = 0; j < 26; j++)
        {
            counts[i + 1][j] += counts[i][j];
        }
    }

    for (size_t q = 0; q < queries; q++)
    {
        int l, r, k;
        std::cin >> l >> r >> k;
        l--;

        int sum = 0;

        for (size_t i = 0; i < 26; i++)
        {
            sum += counts[r][i] - counts[l][i];

            if (sum >= k)
            {
                std::cout << (char)(i + 'a') << std::endl;
                break;
            }
        }
    }
}
0