結果
| 問題 |
No.1471 Sort Queries
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-14 22:28:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 1,416 bytes |
| コンパイル時間 | 1,121 ms |
| コンパイル使用メモリ | 100,596 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 21:16:04 |
| 合計ジャッジ時間 | 3,121 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
//#include <atcoder/all>
#include <bitset>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
//using namespace atcoder;
//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//
void input() {
}
void solve() {
int N, Q; cin >> N >> Q;
string S; cin >> S;
vector<vector<int>> cnt(N, vector<int>(26));
for(int i = 0; i < N; i++) {
if(i > 0) {
for(int j = 0; j < 26; j++) {
cnt[i][j] = cnt[i-1][j];
}
}
int c = S[i] - 'a';
cnt[i][c]++;
}
while(Q--) {
int L, R, X; cin >> L >> R >> X;
L--; R--; X--;
int tmp = 0;
for(int j = 0; j < 26; j++) {
tmp += cnt[R][j];
if(L > 0) tmp -= cnt[L-1][j];
if(tmp > X) {
char c = j + 'a';
cout << c << endl;
break;
}
}
}
}
//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//
int main() {
std::ifstream in("input.txt");
std::cin.rdbuf(in.rdbuf());
std::cin.tie(0);
ios::sync_with_stdio(false);
input();
solve();
return 0;
}