結果

問題 No.1471 Sort Queries
ユーザー racsosaberacsosabe
提出日時 2021-04-09 22:19:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 1,640 ms
コンパイル使用メモリ 163,272 KB
実行使用メモリ 4,560 KB
最終ジャッジ日時 2023-09-07 11:44:27
合計ジャッジ時間 3,271 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 3 ms
4,384 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 4 ms
4,384 KB
testcase_24 AC 4 ms
4,416 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 5 ms
4,468 KB
testcase_28 AC 5 ms
4,444 KB
testcase_29 AC 4 ms
4,384 KB
testcase_30 AC 4 ms
4,384 KB
testcase_31 AC 6 ms
4,384 KB
testcase_32 AC 5 ms
4,384 KB
testcase_33 AC 6 ms
4,392 KB
testcase_34 AC 6 ms
4,548 KB
testcase_35 AC 6 ms
4,388 KB
testcase_36 AC 6 ms
4,560 KB
testcase_37 AC 6 ms
4,552 KB
testcase_38 AC 6 ms
4,488 KB
testcase_39 AC 6 ms
4,488 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘char solve(int, int, int)’ 内:
main.cpp:28:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   28 | }
      | ^

ソースコード

diff #

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