結果

問題 No.1471 Sort Queries
ユーザー hamigakiko0721hamigakiko0721
提出日時 2022-01-31 11:35:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,133 bytes
コンパイル時間 1,586 ms
コンパイル使用メモリ 169,596 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-02 02:07:55
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 8 ms
4,380 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 7 ms
4,380 KB
testcase_20 AC 11 ms
4,376 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 15 ms
4,380 KB
testcase_24 AC 14 ms
4,376 KB
testcase_25 AC 21 ms
4,376 KB
testcase_26 AC 16 ms
4,380 KB
testcase_27 AC 16 ms
4,568 KB
testcase_28 AC 17 ms
4,468 KB
testcase_29 AC 15 ms
4,376 KB
testcase_30 AC 14 ms
4,464 KB
testcase_31 AC 21 ms
4,376 KB
testcase_32 AC 22 ms
4,376 KB
testcase_33 AC 24 ms
4,464 KB
testcase_34 AC 24 ms
4,468 KB
testcase_35 AC 25 ms
4,452 KB
testcase_36 AC 24 ms
4,524 KB
testcase_37 AC 24 ms
4,456 KB
testcase_38 AC 24 ms
4,456 KB
testcase_39 AC 24 ms
4,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
			}
		}
	}
}

0