結果

問題 No.1471 Sort Queries
ユーザー TomorrowNext
提出日時 2021-04-09 22:09:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 170,696 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 05:42:34
合計ジャッジ時間 3,607 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;
using ll = long long;

void Main(string S) {
    int N = S.size();
    int L, R, X;
    cin >> L >> R >> X;
    --L;
    vector<int> nchar(26, 0);
    for (int i = L; i < R; ++i) {
        nchar[S[i] - 'a'] += 1;
    }
    vector<int> s(27, 0);
    s[0] = 0;
    for (int i = 0; i < 26; ++i) {
        s[i + 1] = s[i] + nchar[i];
    }
    int ans = lower_bound(s.begin(), s.end(), X) - s.begin();
    cout << (char)('a' + ans - 1) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    while (Q--) {
        Main(S);
    }
    return 0;
}
0