結果
| 問題 |
No.1471 Sort Queries
|
| コンテスト | |
| ユーザー |
racsosabe
|
| 提出日時 | 2021-04-09 22:19:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 635 bytes |
| コンパイル時間 | 1,524 ms |
| コンパイル使用メモリ | 165,588 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 05:53:14 |
| 合計ジャッジ時間 | 2,907 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
コンパイルメッセージ
main.cpp: In function 'char solve(int, int, int)':
main.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
28 | }
| ^
ソースコード
#include<bits/stdc++.h>
using namespace::std;
const int N = 10000 + 5;
const int E = 26;
int n;
int q;
char s[N];
int ac[E][N];
void preprocess(){
for(int i = 1; i <= n; i++){
for(int j = 0; j < E; j++){
ac[j][i] = ac[j][i - 1];
}
ac[s[i] - 'a'][i] += 1;
}
}
char solve(int l, int r, int k){
int sum = 0;
for(int i = 0; i < E; i++){
int here = ac[i][r] - ac[i][l - 1];
if(sum + here >= k) return i + 'a';
sum += here;
}
}
int main(){
scanf("%d %d", &n, &q);
scanf("%s", s + 1);
preprocess();
int l, r, k;
while(q--){
scanf("%d %d %d", &l, &r, &k);
putchar(solve(l, r, k));
puts("");
}
return 0;
}
racsosabe