結果
| 問題 | No.1471 Sort Queries | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-04-12 11:31:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 18 ms / 2,000 ms | 
| コード長 | 719 bytes | 
| コンパイル時間 | 1,911 ms | 
| コンパイル使用メモリ | 171,372 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-28 09:28:08 | 
| 合計ジャッジ時間 | 3,833 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, q;
   string s;
   cin >> n >> q >> s;
   vector<vector<int>> c(26, vector<int>(n + 1, 0));
   for (int i = 0; i < n; i++) {
       c[s[i] - 'a'][i + 1]++;
   }
   for (int i = 0; i < 26; i++) {
       for (int j = 0; j < n; j++) {
           c[i][j + 1] += c[i][j];
       }
   }
   while(q--) {
       int l, r, x;
       cin >> l >> r >> x;
       int a = 0;
       int ans = 0;
       for (int i = 0; i < 26; i++) {
           a += c[i][r] - c[i][l - 1];
           if (a >= x) {
               ans = i;
               break;
           }
       }
       cout << (char) ('a' + ans) << endl;
   }
}
            
            
            
        