結果

問題 No.1471 Sort Queries
ユーザー kotatsugame
提出日時 2021-04-09 21:26:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 64,640 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 04:04:42
合計ジャッジ時間 2,125 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N,Q;
string S;
int cnt[10101][26];
main()
{
	cin>>N>>Q>>S;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<26;j++)cnt[i+1][j]=cnt[i][j];
		cnt[i+1][S[i]-'a']++;
	}
	for(;Q--;)
	{
		int L,R,X;cin>>L>>R>>X;
		L--;
		int k=0;
		X--;
		while(cnt[R][k]-cnt[L][k]<=X)
		{
			X-=cnt[R][k]-cnt[L][k];
			k++;
		}
		cout<<(char)(k+'a')<<endl;
	}
}
0