結果

問題 No.1471 Sort Queries
ユーザー hir355hir355
提出日時 2021-04-09 22:01:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,785 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 204,344 KB
実行使用メモリ 6,764 KB
最終ジャッジ日時 2023-09-07 11:16:22
合計ジャッジ時間 4,253 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,504 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 8 ms
4,908 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 12 ms
4,900 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 7 ms
4,956 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 12 ms
4,880 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 15 ms
4,908 KB
testcase_24 AC 15 ms
4,852 KB
testcase_25 AC 22 ms
6,700 KB
testcase_26 AC 16 ms
4,904 KB
testcase_27 AC 19 ms
6,756 KB
testcase_28 AC 19 ms
6,704 KB
testcase_29 AC 15 ms
4,880 KB
testcase_30 AC 14 ms
4,904 KB
testcase_31 AC 21 ms
4,840 KB
testcase_32 AC 23 ms
4,856 KB
testcase_33 AC 27 ms
6,740 KB
testcase_34 AC 28 ms
6,756 KB
testcase_35 AC 27 ms
6,728 KB
testcase_36 AC 24 ms
6,760 KB
testcase_37 AC 24 ms
6,712 KB
testcase_38 AC 21 ms
6,760 KB
testcase_39 AC 26 ms
6,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/segtree>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
const long long INF_LL = 2000000000000000000LL;
const int INF = 2000000000;
const long long MOD = 1000000007;
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

typedef vector<vector<edge>> graph;

// using mint = modint998244353;

int op(int a, int b){return a + b;}
int e(){return 0;}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<segtree<int, op, e>> seg(26, segtree<int, op, e>(n));
    rep(i, n){
        seg[s[i] - 'a'].set(i, 1);
    }
    rep(i, q){
        int l, r, x;
        cin >> l >> r >> x;
        int tmp = 0;
        rep(j, 26){
            tmp += seg[j].prod(l - 1, r);
            if(tmp >= x){
                cout << (char)(j + 'a') << endl;
                break;
            }
        }
    }
}
0