結果
| 問題 |
No.1471 Sort Queries
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-31 11:35:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 1,133 bytes |
| コンパイル時間 | 1,619 ms |
| コンパイル使用メモリ | 170,896 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-11 08:47:07 |
| 合計ジャッジ時間 | 3,639 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
template<class T>void chmin(T&a, T b){if(a > b) a = b;}
template<class T>void chmax(T&a, T b){if(a < b) a = b;}
int main(){
int N, Q; cin >> N >> Q;
string S; cin >> S;
//何文字目までに何が何文字あるかの整理
vector<vector<int>> hyou(N+1, vector<int>(26, 0));
for(int i = 0; i < N; ++i){
for(int j = 0; j < 26; ++j){
hyou[i+1][j] += hyou[i][j];
}
hyou[i+1][S[i]-'a']++;
}
/*
cout << endl;
for(int i = 0; i < N; ++i){
for(int j = 0; j < 26; ++j){
cout << hyou[i][j] << " ";
}
cout << endl;
}
*/
//クエリの処理
for(int i = 0; i < Q; ++i){
int L, R, X; cin >> L >> R >> X;
vector<int> tmp(26);
for(int j = 0; j < 26; ++j){
tmp[j] = hyou[R][j] - hyou[L-1][j];
}
for(int j = 0; j < 26; ++j){
X -= tmp[j];
if(X<=0){
cout << char(97+j) << endl;
break;
}
}
}
}