結果
問題 | No.1471 Sort Queries |
ユーザー |
|
提出日時 | 2021-04-09 21:37:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,366 bytes |
コンパイル時間 | 1,859 ms |
コンパイル使用メモリ | 198,480 KB |
最終ジャッジ日時 | 2025-01-20 13:49:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <bits/stdc++.h>#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))#define ALL(x) ::std::begin(x), ::std::end(x)using namespace std;vector<char> solve(int n, int q, const string& s, const vector<int>& l, const vector<int>& r, const vector<int>& x) {vector<array<int, 26> > cnt(n + 1);cnt[0] = {};REP (i, n) {cnt[i + 1] = cnt[i];cnt[i + 1][s[i] - 'a'] += 1;}vector<char> ans(q, '?');REP (j, q) {int k = x[j] - 1;REP (c, 26) {k -= cnt[r[j]][c] - cnt[l[j]][c];if (k < 0) {ans[j] = c + 'a';break;}}}return ans;}// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)int main() {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);constexpr char endl = '\n';int N;int Q;string S;cin >> N >> Q;vector<int> L(Q), R(Q), X(Q);cin >> S;REP (i, Q) {cin >> L[i] >> R[i] >> X[i];-- L[i];}auto ans = solve(N, Q, S, L, R, X);REP (i, Q) { cout << ans[i] << endl; }return 0;}